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...
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...
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...
A Java question. Write the class Staff. It contains methods that manipulate an ArrayList of Strings...
A Java question. Write the class Staff. It contains methods that manipulate an ArrayList of Strings representing the names of staff members. The constructor takes an ArrayList of String names as a parameter. In addition to the constructor, you need to implement the following methods The methods 1. public boolean equals(Staff other) - Determines if the other Staff contains all the same elements in the same order as this Staff 2. public boolean sameContents(Staff other) - Determines if the other...
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a...
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a whole paragraph with punctuations (up to 500 letters) either input from user, initialize or read from file and provide following functionalities within a class: a)   Declare class Paragraph_Analysis b)   Member Function: SearchWord (to search for a particular word) c)   Member Function: SearchLetter (to search for a particular letter) d)   Member Function: WordCount (to count total words) e)   Member Function: LetterCount (ONLY to count all...
You are playing a violin, where the fundamental frequency of one of the strings is 440...
You are playing a violin, where the fundamental frequency of one of the strings is 440 ??, as you are standing in front of the opening of a long tube that is closed at the other end. As you play, you notice that the first time you hear an echo from the tube is when the sound from the 440 ?? string is in its fourth harmonic. Assuming you are playing this string on earth, what must be the length...
Car Race Outcome: Student will demonstrate the ability to generate random numbers Student will demonstrate the...
Car Race Outcome: Student will demonstrate the ability to generate random numbers Student will demonstrate the ability to use a switch statement with cases Student will demonstrate the ability to use loop structures Student will demonstrate the ability to create program logic Student will demonstrate the ability to produce nicely formatted output Program Specifications: You will design a simulated car race. The race will consist of three cars: car A, car B, and car C. Your program will show the...
In this program, you'll create a program that utilizes an enumerated data type to manipulate the...
In this program, you'll create a program that utilizes an enumerated data type to manipulate the array.   Here are the requirements: Write a program that contains an enumerated data type named Letters.    In the declaration, include the following three enumerators: ALPHA, BETA, DELTA. Then, create an array of integers three elements long. The array should be initialized to 0 using a 1-element initialization list. Instead of using integers as subscripts, use the enumerators from your enumerated data type to assign...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT