hemza

programming assignment c language

Write a program that deals with strings. The program should display the following menu:

                  String Handling Program

 Press (a or A) for count the number of 'A' in a given string:

 Press (c or C) for write strings to a file:

 Enter your selection:

  1. If the user chooses A or a, then the program asks the user to enter a string and send the string as a parameter to a method named countLetter(const *char sPtr) which counts the number of ‘A’s letter in the given string.

 

int countLetter(char *sPtr)

 

  1. If the user chooses C or c , then the program asks the user to enter strings and write them into a file named “string.txt”. You should add the strings to the end of the file. Enter / newline ends the input.
  2. If the user enters incorrect choice from menu, the program should show the error message: “Wrong Selection.

 

Sample output:

            String Handling Program

Press (a or A) for count the number of 'A' in a given string:

Press (c or C) for write strings to a file:

Enter your selection:a

Enter a string :BananA

Number of A's in BananA is 3

 

            String Handling Program

Press (a or A) for count the number of 'A' in a given string:

Press (c or C) for write strings to a file:

Enter your selection:c

Enter the strings to be saved into the file:Intro

>> To

>> Programming

>> ^z(EOF)

            String Handling Program

Press (a or A) for count the number of 'A' in a given string:

Press (c or C) for write strings to a file:

Enter your selection:y

Wrong Selection.

Question Attachments

0 attachments —

Pending
Computer Science Assignment Help / Programming Assignment Help
26 Apr 2021
Due Date: 27 Apr 2021

Report As Dispute

Share Your Feedback

Give Review : A+ A B C D F