I was trying out a simple program in c for validating user data. The program is supposed to identify whether a user entered character is a number, alphabet or a special character.
Somehow , the code identifies every kind of input character as a number. I have appended the code below, i'd be grateful if someone could kindly point out where im going wrong ?
//Program to take input from the user and determine whether it is character,number,or a special character
#include<stdio.h>
#include<conio.h>
#include<string.h>
char ch;
int main()
{
clrscr();
printf("Enter a character \n");
scanf("%c \n",ch);
if ((ch>='A'&& ch<='Z')||(ch>='a'&& ch<='z') )
{
printf("The character entered is an alphabet \n" );
}
else if ((ch>=0)&&(ch<=9))
{
printf("Character entered is an number \n");
}
else
{
printf("Character entered is a special character");
}
return 0;
}