Wednesday, July 20, 2011

Program to count no. of vowels in a string

/*Serial No.60     [swami33.cpp]*/

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int count=0,j;
char str[20];
clrscr();
printf("Enter the string==>");
scanf("%s",str);
for(j=0;str[j]!='\0';j++)
{
if(str[j]=='a'||str[j]=='e'||str[j]=='i'||str[j]=='o'||str[j]=='u'||str[j]=='A'||str[j]=='E'||str[j]=='I'||str[j]=='O'||str[j]=='U')
{
count++;
}
}
printf("\nyour total vowels in %s is== %d",str,count);
getch();
}

No comments:

Post a Comment

If you have any doubt, feel free to ask...