-
Notifications
You must be signed in to change notification settings - Fork 112
/
piglatin.cpp
39 lines (36 loc) · 863 Bytes
/
piglatin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*Piglatin word
Place the first vowel of the original word as the start of the new word along with the remaining alphabets with "AY"
For example-
input- LONDON
output- ONDONLAY
*/
#include <iostream>
#include <stdlib.h>
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
int pos=-1;
char ch;
cout<<"\nEnter the word: ";
cin>>s;
transform(s.begin(), s.end(), s.begin(), ::toupper); //converting the word to uppercase
int l=s.length();
for(int i=0;i<l;i++){
ch=s[i];
if(ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U'){ //checking for vowel
pos =i;
break;
}
}
if(pos!=-1)
{
string ans= s.substr(pos)+s.substr(0,pos)+"AY";
cout<<"\nPiglatin word: "<<ans;
}
else
{
cout<<"No piglatin";
}
return 0;
}