Question
C programming language question Write a MENU DRIVEN program to A) Count the number of vowels in the string B) Count the number of consonants
C programming language question
Write a MENU DRIVEN program to
A) Count the number of vowels in the string
B) Count the number of consonants in the string
C) Convert the string to uppercase
D) Convert the string to lowercase
E) Display the current string
X) Exit the program
The program should start with a user prompt to enter a string, and let them type it in. Then the menu would be displayed. User may enter option in small case or capital letter both.
The string input may be a long sentence, with the newline indicating the end of the string. Define the character array as a global array that may be used amongst the different functions, so the functions would be void and no parameters passed to them
Assume that the string is max 100 characters, so declare your array accordingly.
When the A or B commands are entered (counting vowels or consonants), call the Corresponding Function, then print the result from main()
When the C or D commands are chosen, just call the appropriate function to convert the string. Ensure that output is done in main function again.
When E is chosen, print the contents of the stored string.
There are 4 functions needed to be defined. Each of these functions should have a single parameter -- accepting a c-style string as an argument. The function should only do what is specified (note that none of these functions do any output to the screen). You must define prototype for the functions. Function 1 and 2 return int and Function 3 and 4 are void functions.
Write a function that counts and returns the number of vowels in the string. (For the purposes of this exercise, we are talking about the standard 5 vowels -- A, E, I, O, U).
Write a function that counts and returns the number of consonants in the string.
Write a function that converts the string to all lowercase.
Write a function that converts the string to all uppercase.
Sample Run
Please Input text: The quick brown fox jumped. The lazy dog, he was jumped over.
A) Count the number of vowels in the string
B) Count the number of consonants in the string
C) Convert the string to uppercase
D) Convert the string to lowercase
E) Display the current string
X) Exit the program
Make a selection: a
Number of vowels: 16
Make a selection: B
Number of consonants: 31
Make a selection: c
Make a selection: e
The string:
THE QUICK BROWN FOX JUMPED. THE LAZY DOG, HE WAS JUMPED OVER.
Make a selection: D
Make a selection: E
The string:
the quick brown fox jumped. the lazy dog, he was jumped over.
Enter your menu selection: x
Goodbye
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started