Thursday, March 25, 2010

A simple C++ program..

One of my colleague wanted the simplest and shortest program for indentifying whether the input is alphabet, letter or symbol.. I gave this solution. Tell me if you can write the shorter one..!

#include 
#include

void main()
{
clrscr();
char charac;
cout << "Enter your input : " << endl;
cin>>charac;
if(((charac>='A')&&(charac<='Z'))||((charac>='a')&&(charac<='z')))
cout << "Your input " << charac << " is a character." << endl;
else if((charac>='0')&&(charac<='9'))
cout << "Your input " << charac << " is a digit." << endl;
else
cout << "Your input " << charac << " is a symbol." << endl;
getch();
}

1 comment:

Abhimanyu said...

Next will be the programs on dot net languages..!! Keep bugging..!!