Display the number of vowels in a given character array using pointers

Display the number of vowels in a given character array using pointers

Program to display the number of vowels in a given character array using pointers is discussed here.

Let us consider a sample character array: FACE Prep. The number of vowels is 3 and consonants is 5.




Find number of vowels in a character array


The algorithm to display the number of vowels is as given below:

  • Read a string as input from the user.
  • Assign the address of the string to the character pointer.
  • Increment the pointer when the character is a vowel.




Input the string from the user. Assign the input character array to the pointer. Scan all the input characters. If it is a vowel, increment the cntV variable and if it is a consonant, increment the cntC variable. After all the characters are scanned, display the total number of vowels and consonants.




Program to display the number of vowels in a given character array

@@coding::1@@




Recommended Programs



Find number of vowels in a character array

c