Question: #include #include using namespace std; int main ( ) { / / declaring an stl string and taking input from user string str; cin >

#include
#include
using namespace std;
int main()
{
// declaring an stl string and taking input from user
string str;
cin >> str;
// store first character of the string into another variable
char x = str[0];
// if the character is a vowel, add "way" to the end of the string
if (x =='a'|| x =='e'|| x =='i'|| x =='o'|| x =='u'){
string temp("way");
str = str + temp;
}
// else delete the first character and add it at the end along with string "ay"
else {
str.erase(0,1);
str.push_back(x);
str = str +"ay";
}
// print the string
cout << str;
system("Pause");
return 0;
}
The assignment asks you to convert entire sentences into pig latin, rather than a single word. You'll want to find a way to store the entire sentence somewhere, and then convert each word in that sentence to pig latin, replacing them as you go.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!