Number of vowels in a string in c language.
Number of vowel in string.
This programme count the number of vowel in c language.The following programmme has used the following method.
- Take the input string from the user.
- Find the length of the string.
- Run the iteration till the length of the string.
- Apply the condition for checking the vowel.
- If the condition is true then increment the integer variable for counting the number of vowel.
- And then display the result.
Counting the vowel in string.
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
void main()
{
char str[30];
int i,count=0;
printf("Enter your string");
gets(str);
len=strlen(str);
for(i=0;i<len;i++)
{
if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u')
{
count++;
}
}
printf("Number of vowels in string is :%d\n",count);
getch();
}
output will be like this:
Enter your string : Deepak
Number of vowels in string is:
3
Number of vowels in a string in c language.
Reviewed by Deepak kumar soni
on
December 17, 2018
Rating:
check it out for more.
ReplyDelete