Write a C Program to Count Number of vowels in a given sentence
Source code
#include<stdio.h>
void main()
{
char str[100];
int i,count=0;
printf("Enter the sentence to count vowels:");
gets(str);
for(i=0;str[i]!='\0';i++)
{
if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'||str[i]=='A'||str[i]=='E'
||str[i]=='I'||str[i]=='O'||str[i]=='U')
{
count++;
}
}
printf("\nNumber of vowels in given sentence: %d\n",count);
}
Output
Enter the sentence to count vowels:This is a program to count vowels
Number of vowels in given sentence: 10
No comments:
Post a Comment