Monday, May 5, 2008

program to find alphabet, digit or symbol

Write a program that will ask the user to enter a single character. Find out whether it is alphabetic, digit or special character.

PROGRAM:

#include <iostream.h>

#include <conio.h>

#include <stdio.h>

#include <ctype.h>

void main() {

clrscr();

char ch;

cout<<"Enter either digit, alphabet or special symbol: ";

ch=getchar();

if(isalpha(ch)) {

cout<<"You entered alphabet\n";

}

else if(isdigit(ch)) {

cout<<"You entered digit\n";

}

else

cout<<"You entered special symbol";

getch();

}//end of the program

No comments: