Showing posts with label small letter to capital letter. Show all posts
Showing posts with label small letter to capital letter. Show all posts

Saturday, August 22, 2015

Change Case of a Word

Q. 101. C++ Program to accept a word and change the Upper case (capital) letters to Lower case (small) and Lower case letters to Upper case.



Copy Code:

#include <iostream>
using namespace std;

int main()

{
  char ch [50]; int i = 0;
  cout << "Enter a Word : ";
  cin >> ch;
  while( ch[ i ] != '\0' )
  {
     if ( ch[ i ] >= 'a'  &&  ch[i] <= 'z' )
         ch [ i ] = ch [ i ] - 32;
     else 
     if ( ch[ i ] >= 'A'  &&  ch[i] <= 'Z' )
         ch [ i ] = ch [ i ] + 32;

     ++i;
   }
  cout << "Word with Changed Case is : "<< ch;
  return 0;
}