Write a program to find the number of vowels and consonants

//this is a program to find the number of vowels and consonants
#include<stdio.h>
#include<conio.h>
void main()
{
char str[20];
int i=0,vowel=0,cons=0;

printf("\n\nEnter your name: ");
scanf("%s",str);

while(str[i]!=NULL)
{
if((str[i]=='a')||(str[i]=='e')||(str[i]=='o')||(str[i]=='i')||(str[i]=='u'))
vowel++;
else if((str[i]=='A')||(str[i]=='E')||(str[i]=='I')||(str[i]=='O')||(str[i]=='U'))
vowel++;
else
cons++;
i++;
}

printf("\n\nVowels: %d\n\nConsonants: %d",vowel,cons);
getch();
}

Previous
Next Post »