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