Remove consonants from a string
Given a string s, remove all consonants and prints the string s that contains vowels only.
Input: The first line of input contains integer T denoting the number of test cases. For each test case, we input a string.
Output: For each test case, we get a string containing only vowels. If the string doesn't contain any vowels, then print "No Vowel"
Input: The first line of input contains integer T denoting the number of test cases. For each test case, we input a string.
Output: For each test case, we get a string containing only vowels. If the string doesn't contain any vowels, then print "No Vowel"
Constraints:
1<=T<=100
The string should consist of only alphabets.
Examples:
For Input:
2
HmlMqPhBfaVokhR
wdTSFuI IvfHOSNv
Your Output is:
ao
uI IO
2
HmlMqPhBfaVokhR
wdTSFuI IvfHOSNv
Your Output is:
ao
uI IO
#include<iostream>
using namespace std;
int main()
{
int input;
cin>>input;
char x[100]={'\0'};
for(int i = 0;i<=input;i++)
{
x[0]='\0';
cin.getline(x, 100);
if(i!=0)
{
for(int count2=0 ; x[count2]!='\0';count2++)
{
bool flag = 0;
switch(x[count2])
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
case ' ':
cout<<x[count2];
flag = 1;
break;
default: break;
}
}
if(flag = 0) cout<<"No Vowel";
cout<<endl;
}
}
}
Comments
Post a Comment