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. 

  1. Take the input string from the user.
  2. Find the length of the string.
  3. Run the iteration till the length of the string.
  4. Apply the condition for checking the vowel.
  5. If the condition is true then increment the integer variable for counting the number of vowel.
  6. 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. Number of vowels in a string in c language. Reviewed by Deepak kumar soni on December 17, 2018 Rating: 5

1 comment:

Powered by Blogger.