0
1.9kviews
Write a program to calculate number of vowels (a, e, i, o, u) separately in the 6 entered string.

Subject : Structured Programming Approach

Title : Arrays, String, Structures and Union

Difficulty : Medium

1 Answer
0
66views

program:

#include <stdio.h>

#include<conio.h>

void main()

{

    int c = 0, count = 0,a=0,i=0,e=0,o=0,u=0,A=0,I=0,E=0,O=0,U=0;

    char s[1000];

    clrscr();

    printf("Input a string\n");

    gets(s);

    while (s[c] != '\0')

    {

        if (s[c] == 'a')

        {

            a++;

            printf("\na=%d",a);

        }

        else  if (s[c] == 'A')

        {

            a++;

            printf("\nA=%d", a);

        }

        else  if(s[c] == 'e')

        {

            e++;

            printf("\ne=%d",e);

        }

        else  if (s[c] == 'E')

        {

            e++;

            printf("\nE=%d",E);

        }

        else  if (s[c] == 'i')

        {

            i++;

            printf("\ni=%d",i);

        }

        else  if(s[c] == 'I')

        {

            i++;

            printf("\nI=%d",I);


        }

        else  if (s[c] == 'o')

        {

            o++;

            printf("\no=%d",o);

        }

        else if (s[c] == 'O')

        {

            O++;

            printf("\nO=%d",O);

        }

        else  if(s[c] == 'u')

        {

            u++;

            printf("\nu=%d",u);

        }

        else  if (s[c] == 'U')

        {

            U++;

            printf("\nU=%d",U);

        }

        count++;

        c++;

    }

    getch();

}

Output:

Input string University

U=1

i=2

e=1
Please log in to add an answer.