Enter a string: house
(a)esuoH
(b)ESUOH
(c)esuoh
(d)EhuoS (Last and 2nd letter changed positions)
- I'm done with (b) and (c), and I don't know how to execute the remaining 2. Any suggestions?
Here's my code:
#include <iostream>
#include <string>
#include <locale>
using namespace std;
int main ()
{
do
{
system("CLS");
string input;
cout<<"Enter a string: ";
cin>> input;
string str (input);
cout<<"\n\n";
locale loc;
//for letter (b)
string::reverse_iterator rit;
for ( rit=str.rbegin() ; rit < str.rend(); rit++ )
cout << toupper(*rit,loc);
cout<<"\n\n";
//for letter (c)
for ( rit=str.rbegin() ; rit < str.rend(); rit++ )
cout << tolower(*rit,loc);
cout<<"\n\n";
do
{
cout<<"Do you want to try again?: [y/n] ";
cin>>again;
}while(again!='Y'&&again!='y'&&again!='N'&&again!='n');
if (again=='n'||again=='N')
{
system ("CLS");
cout<<"\n\n\n\n";
cout<<"Thank you for using this system.";
cout<<"\n\n\n\n";
return 0;
}
}while(again=='Y'||again=='y');
return 0;
}