(Printing a string Backward) Write a program that inputs a string and prints the string backward. Convert all uppercase characters to lowercase and all lowercase characters to uppercase.
What will be an ideal response?
```
#include
#include
using namespace std;
int main()
{
string s;
cout << "Enter a string: ";
getline( cin, s, '\n' );
// r is set to the beginning of the reverse sequence from s
string::reverse_iterator r = s.rbegin();
// loop until rend is reached
while ( r != s.rend() )
{
// convert all characters to its opposites
*r = ( isupper( *r ) ? tolower( *r ): toupper( *r ) );
cout << *( r++ ); // next character
} // end loop
cout << endl;
} // end main
```
Enter a string: The sinking of HMS Titanic
CINATIt smh FO GNIKNIS EHt
You might also like to view...
What kinds of curve and surface continuity can be achieved in Rhino?
What will be an ideal response?
A(n) ________-as-a-Service provides a programming environment in which custom web applications can be developed, tested, and deployed
Fill in the blank(s) with correct word
Write a CSS rule that centers an element horizontally in 60% of the browser window’s width.
What will be an ideal response?
You cannot disable some USB devices from end-user computers and allow others
Indicate whether the statement is true or false.