Sample – Program to identify if an input is a symbol, digit or character.

by Nideesh C on February 8, 2011 · 0 comments

in C++




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

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.

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. Sample – Program to convert 2-digit octal number into binary number and print it.
  2. Sample – Program to enter an integer and output it in the reversed form.
  3. Sample – Program to compute the fibonacci series.
  4. Sample – Program to find the roots of a quadratic equation.
  5. Sample – Program to enter a string and find its length.

Leave a Comment

Previous post:

Next post: