Jump to content

To count the number of vowels in a word

From IdeaWazaWiki
Revision as of 13:55, 19 December 2006 by 203.115.85.233 (talk) (New page: <pre> →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 (...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
/* 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();
}