Question

In: Computer Science

Playing with strings Assignment Outcomes: Demonstrate the ability to create strings. Demonstrate the ability to manipulate...

Playing with strings Assignment

Outcomes:

  • Demonstrate the ability to create strings.
  • Demonstrate the ability to manipulate strings.
  • Demonstrate the ability to write well written code.

Program Specifications:

DESIGN and IMPLEMENT a short program that will:

  • Allow the user to enter a string with up to 100 letters.
  • Display the user-entered string:
    • Forward
    • Backward
    • Vertical
    • As a triangle made from the letters of the string
  • Display the number of letters in the string.
  • Once everything above is displayed, the program will ask the user if he or she wishes to enter a different string or quit.

Hint: Use a technique to read in strings that allows spaces:

https://www.programmingsimplified.com/c/program/print-string

Submission Requirements:

Requirements will be same as the first assignment which will be the same for all future assignments.

DO NOT:

  • Use global variables, in this or any program ever.
  • Use goto statement(s) , in this or any program ever.

Solutions

Expert Solution

#include <stdio.h>
int main()
{
   char z[100];
   int n=1;
   do{
       printf("Enter a string\n");
       gets(z);
       printf("\nThe string in forward: ");
       int size=0;
       while(z[size]!='\0')
       {
           printf("%c",z[size]);
           size++;
       }
       printf("\nThe string in backward: ");
       for(int i=size-1;i>=0;i--)
           printf("%c",z[i]);
      
       printf("\nThe string verticaly is\n");
       for(int i=0;i<size;i++)
           printf("%c\n",z[i]);
       int k=0;
       printf("\nThe string in the form of triangle is:\n");
       for(int i=0;i<5&&k<size;i++)
       {
           for(int j=5;j>i;j--)
               printf(" ");
          
           for(int j=0;j<=i&&k<size;j++)
           {
               printf("%c ",z[k]);
               k++;
           }
           printf("\n");
       }
      
       int no=0;
       for(int i=0;i<size;i++)
       {
           if((z[i]>='a'&&z[i]<='z')||(z[i]>='A'&&z[i]<='Z'))
               no++;
       }
       printf("\nThe numbers of letter in the string is : %d\n",no);
       printf("Enter 1 to enter one more string else 0");
       scanf("%d",&n);
   }while(n==1);
return 0;
}


Related Solutions

"Gambling Greg" Assignment Outcomes: Demonstrate the ability to create and use structs Demonstrate the ability to...
"Gambling Greg" Assignment Outcomes: Demonstrate the ability to create and use structs Demonstrate the ability to create and use menus Demonstrate the ability to create and use an array of structs Demonstrate the ability to generate and use random numbers Program Specifications: Assume that gambling Greg often goes to the Dog Racing Track. Greg loves to bet on the puppies. In each race Greg will place a wager and pick a dog. The dog information will be stored in a...
"Gambling Greg" Assignment Outcomes: Demonstrate the ability to create and use structs Demonstrate the ability to...
"Gambling Greg" Assignment Outcomes: Demonstrate the ability to create and use structs Demonstrate the ability to create and use menus Demonstrate the ability to create and use an array of structs Demonstrate the ability to generate and use random numbers Program Specifications: Assume that gambling Greg often goes to the Dog Racing Track. Greg loves to bet on the puppies. In each race Greg will place a wager and pick a dog. The dog information will be stored in a...
Struct PERSON Assignment Outcomes: Demonstrate the ability to create structs using typedef Demonstrate the ability to...
Struct PERSON Assignment Outcomes: Demonstrate the ability to create structs using typedef Demonstrate the ability to create an array of structs Program Specifications: DESIGN and IMPLEMENT a program that will CREATE and use three different variables of type PERSON. Create a struct using the typedef command for a DATE. Create a struct for a PERSON with the following fields. name [this will be a string] birthdate [this will be a DATE] gender [this will be a char] annualIncome [this will...
Struct PERSON Assignment Outcomes: Demonstrate the ability to create structs using typedef Demonstrate the ability to...
Struct PERSON Assignment Outcomes: Demonstrate the ability to create structs using typedef Demonstrate the ability to create an array of structs Program Specifications: DESIGN and IMPLEMENT a program that will CREATE and use three different variables of type PERSON. Create a struct using the typedef command for a DATE. Create a struct for a PERSON with the following fields. name [this will be a string] birthdate [this will be a DATE] gender [this will be a char] annualIncome [this will...
Struct PERSON Assignment Outcomes: Demonstrate the ability to create structs using typedef Demonstrate the ability to...
Struct PERSON Assignment Outcomes: Demonstrate the ability to create structs using typedef Demonstrate the ability to create an array of structs Program Specifications: DESIGN and IMPLEMENT a program that will CREATE and use three different variables of type PERSON. Create a struct using the typedef command for a DATE. Create a struct for a PERSON with the following fields. name [this will be a string] birthdate [this will be a DATE] gender [this will be a char] annualIncome [this will...
#C language array must store at least 50 inputs Game Scores Assignment Outcomes: Demonstrate the ability...
#C language array must store at least 50 inputs Game Scores Assignment Outcomes: Demonstrate the ability to create a menu driven program. Demonstrate the ability to create and use a 2D array on the stack. Demonstrate the use of functions. Demonstrate good programming style. Program Specifications: Your program will read in "game scores" from the user. Each score consists of a score for YOUR team and a score for the OTHER team. You don't need names or dates for the...
Purpose The purpose of this assignment is to give you an opportunity to demonstrate your ability...
Purpose The purpose of this assignment is to give you an opportunity to demonstrate your ability to identify emerging ethical issues in business, interpret the multitude of perspectives inherent in your case study, and model appropriate behaviour by recommending specific solutions. How to Proceed Select a case. It can be one of the textbook cases that we have not discussed during the course. It can also come from the outside world, perhaps a case you have been following in the...
Policy Drivers The purpose of this assignment is to practice and demonstrate your ability to interpret...
Policy Drivers The purpose of this assignment is to practice and demonstrate your ability to interpret detailed policy. We have chosen for you to take a look at two of the most well known policies; in real life, you will have government polices such as these as well as enterprise specific policies or regulations. As you build information systems, it is key to early on in the process to identify all relevant policy drivers and understand them. In the module,...
In this assignment, you need to demonstrate your ability in using input, output, data types, and...
In this assignment, you need to demonstrate your ability in using input, output, data types, and if statement in C++ program. Assume that you need write a C++ program for a cash register. There are only four items in the store: Cereal, $3.99 Milk, $3.99 Egg, $0.25 Water, $ 1.50 Once a customer purchases items, you will ask her/his how many of them are bought. The quantity can be in the range of 0-10 (including 0 and 10). Then, calculate...
C Programming Game Scores Assignment Outcome: Student will demonstrate the ability to design a menu driven...
C Programming Game Scores Assignment Outcome: Student will demonstrate the ability to design a menu driven program. Student will demonstrate the ability to create and use a 2D array on the stack. Student will demonstrate the use of functions. Student will demonstrate good programming style. Program Specifications: *********************************************** ** MAIN MENU ** *********************************************** A) Enter game results B) Current Record (# of wins and # of losses and # of ties) C) Display ALL results from all games WON D)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT