Saturday, September 10, 2011

C Program Algorithm To Count Number Of Vowels Blank Spaces Words

Program

#include<stdio.h>
#include<string.h>
main()
{
char a[50],b[50];
int i,l,count=0,sp=0;
printf("enter the string:\n");
scanf("%s",b);
l=strlen(b);
for(i=0;i<l;i++)
{
a[i]=toupper(b[i]);
for(i=0;i<l;i++)
{
if(a[i]=='A'||a[i]=='E'||a[i]=='O'||a[i]=='U')
count+1;
else if(a[i]==' ')
sp=sp+1;
}}
printf("Number of vowels in the string=%d ",count+1);
printf("Number of space=%d",sp);
printf("No of word=%d",sp+1);
}

Output
Enter the string
god is great
Number of vowels in the string=4
Number of space=2
No of word=3

No comments:

Post a Comment