Write A Program To Count The Number Of Vowels And Consonants In A Given Srting?

1

1 Answers

Anonymous Profile
Anonymous answered
Start with 3 variables, your string as a character array, a variable to hold the number of vowles and a variable to hold the number of consonants. Now write a loop to go through each letter one by one. Use a switch statment to see if it is a, e, I, o or you and if so add one to the number of vowles. If not add one to the number of consonants. Keep this loop running untill it reaches the end of the string. In your switch statment also have a case for spaces, if this occurs add one to neither the vowles variable or the consonants variable. You can then do what you want with these variables, eg: Print them, add them, etc...

Answer Question

Anonymous