char variable

how do i use a char variable in an if statement

for eg.
1
2
3
4
5
6
7
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
char a;
cin>>a;


after this I have to check whether the character is a digit or a character.
i havent been taught arrays and i cannot use #include<ctype.h>

Please tell me how to use the char variable in an if statement.
Thank you in advance.
the character a is represented as 'a', which just translates into the integer value 97.
 
if (a >= 'a' && a <= 'z') //if the char in variable a is between lowercase a and lowercase z 


you can do the same with '0' and '9', 'A' and 'Z', etc

http://www.asciitable.com/
Last edited on
It worked.
Thank you.
no problem
Topic archived. No new replies allowed.