Print Friendly and PDF
Write a program that inputs a string and prints the string backwards. Convert all uppercase characters to lowercase and all lowercase characters to uppercase.
Write a program that inputs a string and prints the string backwards. Convert all uppercase characters to lowercase and all lowercase characters to uppercase.


Solution:

#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
string s;
cout << "Enter a string: ";
getline( cin, s, '\n' );
string::reverse_iterator r = s.rbegin();
while ( r != s.rend() )
{
*r = ( isupper( *r ) ? tolower( *r ): toupper( *r ) );
cout << *( r++ );
}
cout << endl; return 0;}
Output:

Enter a string: This is Programming WEBSITE
etisbew GINMMARGORp SI SIHt

zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: