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;
}

Edited 6 Years Ago by __avd: Added [code] tags. Encase your code in: [code] and [/code] tags.

For part a) make a copy. For that copy, uppercase the first letter. Print it backwards.

For part d) make a copy. Swap certain positions. Print out the copy
backwards.

For part a) make a copy. For that copy, uppercase the first letter. Print it backwards.

For part d) make a copy. Swap certain positions. Print out the copy
backwards.

-But i don't know how to code this..., any help?

-But i don't know how to code this..., any help?

something like this :

for part a :

string input = "";
cin >> input;
string copyInput = input;
copyInput[0] = toupper(copyInput[0] ); //make it upper case
//then print it backwards

I assume if you couldn't get this then the code you presented
is not completely yours?

You should write this

void main(){
        cout<<"Hello World.";
        system("pause");

        return 0;
            }

just declare again
like that...

    int main ()
    {
        char again;
        do
        {
        }while
    }
This article has been dead for over six months. Start a new discussion instead.