Thursday, 2 October 2014

WAP to count no. of Vowels ,Consonant and spaces in a String


#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
char s[100];
char *a=s;
int m=0, x=0,p=0,k=0;
printf("\nEnter the String ");
gets(s);
while(*a)
{
a++;
m++;
}
for(int i=0;i<m;i++)
{
if(s[i]==' ')
{
k++;
}
else
if(s[i]=='a' || s[i]=='A' || s[i]=='e' || s[i]=='E' || s[i]=='i' || s[i]=='I' || s[i]=='o' || s[i]=='O' || s[i]=='u' || s[i]=='U')
{
p++;
}
else{
x++;
}
}
printf("\n\tVowel in String is : %d " ,p);
printf("\n\tSpaces in String is : %d " ,k);
printf("\n\tconstraint in String is : %d " ,x);
getch();

}

No comments:

Post a Comment

Please write your doubts