Question:
To find the number of vowels present in a sentence.
Test Case:
Solution:
#include <stdio.h>
#include <conio.h>
int main()
{
int cha,i,c=0;
char ch,str[40]="";
printf("enter string : ");
scanf("\n %s",str);
for(i=0;str[i]!='\0';i++)
{
cha = str[i];
switch(cha){
case'a' :
case'A' :
case'e' :
case'E' :
case'i' :
case'I' :
case'o' :
case'O' :
case'u' :
case'U' :
c++;
}
}
printf("\nTotal number of vowels is %d",c);
return 0;
}
#include <conio.h>
int main()
{
int cha,i,c=0;
char ch,str[40]="";
printf("enter string : ");
scanf("\n %s",str);
for(i=0;str[i]!='\0';i++)
{
cha = str[i];
switch(cha){
case'a' :
case'A' :
case'e' :
case'E' :
case'i' :
case'I' :
case'o' :
case'O' :
case'u' :
case'U' :
c++;
}
}
printf("\nTotal number of vowels is %d",c);
return 0;
}