"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Tuesday, March 16, 2010

Write a program to accomplish the following functions specified below.

handle( a-character) returns the reversed case of the passed character or prints it twice depending upon whether you assign the return value to it or not.


#include<iostream.h>
#include<conio.h>


void handle(char ch)
{
cout<< ch << " " << ch;
}

int handle(int ch)
{
if(ch > = 65 && ch < = 90) // ASCII CODE of A = 65,Z=90
  ch =ch + 32;
else
   { if(ch > = 97 && ch < = 122) // ASCII code of a=97,z=122
           ch = ch - 32;
    }
return ch;
}
     
void main()
{
cout<< "\n Enter a character :";
char c;
cin >> c;

// To print the character twice
handle(c);


cout<<"\n\n" ;

// To reverse the character
int a = handle(c);

cout<< "\n The reverse character of " < < c << "is " << (char)a;

getch();
}

No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.