Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

program for reading number of vowels in string also tell about the missing vowels

0 votes
asked May 21, 2019 by dd
Create an algorithm for a program that reads a string with a maximum length of 30 from the keyboard. The algorithm should then copy the characters from that string into a second character array in order but only if the character is a vowel (a, e, i, o, u). Once copied, the algorithm should output these values in order. The algorithm should then count and display the number of times each vowel appears in the array. Finally, the algorithm should also output the index in the second array where each vowel first appeared or a suitable message if a particular vowel is not in the array at all.

1 Answer

0 votes
answered May 21, 2019 by thilipan
#include <stdio.h>

int main()
{
  char a[30];
  char b[30];
  int i,j=0,a1=0,e=0,i1=0,o=0,u=0;
  scanf("%s",a);
  for(i=0;i<strlen(a);i++)
  {
      if((a[i]=='a')||(a[i]=='e')||(a[i]=='i')||(a[i]=='o')||(a[i]=='u'))
      {
          b[j]=a[i];
          j++;
      }
  }
  for(i=0;i<j;i++)
  {
      printf("%c",b[i]);
  }
  for(i=0;i<j;i++)
  {
      switch(b[i])
      {
            case 'a':
                a1++;
                break;
            case 'e':
                e++;
                break;
            case 'i':
                i1++;
                break;
            case 'o':
                o++;
                break;
            case 'u':
                u++;
                break;
       }
  }
  printf("a=%d,e=%d,i=%d,o=%d,u=%d",a1,e,i1,o,u);
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...