program to count the vowel in the string in c-programming.
In the program both lower and upper case are considered i.e., 'a', 'A', 'e', 'E', 'i', 'I', 'o', 'O', 'u' and 'U'. In this program we check every character in the input string, if it's a vowel then counter is incremented by one, consonants and special characters are ignored.
//program to count the vowel in the string
#include<stdio.h>
#include<conio.h>
void main()
{
char str[40],v[]="aeiouAEIOU";
int i,j,count=0;
printf("enter the string:-");
gets(str);
for(i=0;str[i];i++){
for(j=0;v[j];j++){
if(str[i]==v[j]){
count++;
break;
}
}
}printf("no of vowel in the string is %d",count);
getch();
}
output:-
for more c-programming:-
1.c-program to count the length of string without using strlen function

No comments:
Post a Comment