Followers

Saturday, December 10, 2011

INTER CONVERSION OF CASES OF ALPHABET--USING LOGIC

#include<iostream.h>
#include<conio.h>
char ch;

char cse(char ch)
{

 if((97<=int(ch))&&(int(ch)<=122))
   {
    cout<<"\nThe given character is in lowercase"
      <<"\nThe corresponding uppercase is - ";
    return(char(int(ch)-32));
   }
 else if (65<=int(ch)<=90)
   {
    cout<<"\nThe given character is in uppercase"
      <<"\nThe corresponding lowercase is - ";
    return(char(int(ch)+32));
   }
}
void main()
{
  clrscr();
  cout<<"Enter a character : ";
  cin>>ch;
  cout<<cse(ch);
  getch();
}
.................................................................
OUTPUT:(click to enlarge the image)

2 comments:

  1. And what if i wanna convert a whole word or sentence??? :?

    ReplyDelete
  2. refer to this program : http://basiccplusplus-asim.blogspot.com/2012/01/case-conversion-in-string-using-logic.html

    ReplyDelete