Atleast One Vowel ID:6888

 

The program must accept a string as the input. The program must print the word(s) which contains atleast one vowel. If all the words contain only consonants then the program must print -1 as the output.

Boundary Condition(s):
1 <= Length of S <= 1000

Example Input/Output 1:
Input:
The Sky is Blue

Output:
The is Blue
    
Explanation:
The word "The" contains one vowel e.
The word "Sky" contains no vowel.
The word "is" contains one vowel i.
The word "Blue" contains two vowels and e.
Hence "The is Blue" is printed as the output.

Example Input/Output 2:
Input:
Good Morning

Output:
Good Morning

PROGRAM IN C:

#include<stdio.h>

#include<stdlib.h>

int vow(char z[])

{int a=0;


    for(int i=0;i<strlen(z);i++)

    {

       char f=tolower(z[i]);

    if(f=='a' ||f=='e'||f=='i'||f=='o'||f=='u')

          a++;  

    }

    return a;

}

int main()

{

char s[1000];

int x=0;

while(scanf("%s",s)>0)

{    if(vow(s))

    {

        printf("%s ",s);

        x=1;

    }

}

if(x==0)

printf("-1");

Comments

Popular Posts