To count the number of vowels in a word
Appearance
/* Program to count no. of vowels in a word. */
#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
char word[20];
int l, n = 0, i = 0;
clrscr();
printf ("\n Enter any word: ");
scanf ("%s", word);
l = strlen (word);
for (i = 0; i < l; i++)
{
if ( (word[i] == 'a') || (word[i] == 'e')
|| (word[i] == 'i') || (word[i] == 'o') || (word[i] == 'u')
|| (word[i] == 'A') || (word[i] == 'E') || (word[i] == 'I')
|| (word[i] == 'O') || (word[i] == 'U'))
n++;
}
printf ("\n The no. of vowels in '%s' are %d", word, n);
getch();
}