Header Ads Widget

Double the Vowel characters in the string | unthinkable solutions

 Program to double the vowel characters in the string :

Given a string , write a program to double the vowel characters in the string .

Sample input :-

Easy

Sample output:-

EEaasy



Program to double the vowel character in the string :-

The objective of the code is to double the vowel characters (a,e,i,o,u ,A, E,I,O,U) in the string .



Code:-

#include<bits/stdc++.h>
using namespace std;

// function to check vowel
int IsVowel(char ch)
{
ch=tolower(ch);
if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u')
return 1;
return 0;
}
int main()
{
string str;
char res[1000];
int k=0;
cout<<"Enter the string"<<endl;
cin>>str;
for(int i=0;i<str.size();i++)
{
if(IsVowel(str[i]))
{
res[k++]=str[i];
}
res[k++]=str[i];
}
res[k]='\0';
cout<<"Final string is :"<<endl;
cout<<res;
return 0;
}

Output:-

Enter the string
EasyCodingZone
Final string is :
EEaasyCoodiingZoonee

Wipro :-

Infytq :-

Key Points;-

Hackerrank:-


C-tutorial:-

See more:-