Wednesday, December 10, 2014

// WAP  TO COUNT NO. OF VOVELS AND CONSONENTS IN A ENTERED STRING


#include<stdio.h>
//#include<conio.h>
#include<string.h>
void main()
{
char str[50];
int vovels=0,consonants=0,len,i;
printf("Enter the String:\n");
gets(str);
len=strlen(str);
for(i=0;i<len;i++)
{
 if((str[i]>64&&str[i]<91)||(str[i]>96&&str[i]<123)) //Firstly checking the character is alphabet or not
 {
if(str[i]=='a'||str[i]=='A'||str[i]=='e'||str[i]=='E'||str[i]=='i'||str[i]=='I'||str[i]=='o'||str[i]=='O'||str[i]=='u'||str[i]=='U') //checking if it is vowel or not
vovels++;
else
consonants++;
  }
}
printf("Number of vovels = %d and consonants = %d ", vovels , consonants);
//getch();
}

No comments:

Post a Comment