Calculating Number of Vowels in a Word

Problem Statement
Write a c program to read a word and return the number of vowels in it
#include<stdio.h>
int noofvowel(char temp[]);
int main()
{
  int y;
  char temp[20];
  printf("enter the string \n");
  scanf("%s",temp);
  y=noofvowel(temp);
  printf("%d vowels found \n",y);
  return 0;
}
int noofvowel(char temp[])
{
  int i=0,j=0;
  while(temp[i]!='\0')
    {
      if(temp[i]=='a'||temp[i]=='i'||temp[i]=='e'||temp[i]=='o'||temp[i]=='u')
        {
          printf("%c \n",temp[i]);
          j++;
        }
      i++;
    }
  return j;
}


No comments:

Post a Comment