BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   Object Oriented Programming (http://bzupages.com/322-object-oriented-programming/)
-   -   Program to identify if an input is a symbol, digit or character (http://bzupages.com/f322/program-identify-if-input-symbol-digit-character-14663/)

bonfire 09-03-2011 12:11 AM

Program to identify if an input is a symbol, digit or character
 
1 Attachment(s)
Program to identify if an input is a symbol, digit or character


#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();
}
This program takes in a character, a digit or a symbol charac as a screen input from the user.
It then identifies whether the input is a symbol, a digit or a character and outputs the appropriate message using the 'cout' command.
Sample Input
#
Sample Output
Your input # is a symbol.


All times are GMT +5. The time now is 03:49 PM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.