I wrote a program that is supposed to evaluate a character that the user types in and tell the user if it's a number, a letter, etc.
The problem is that the program always goes to 'else' and returns the wrong answer!
Code:
#include <stdio.h>
int main()
{
int cod;
char c;
cod= (int) c;
printf("Type one character");
scanf("%c", &c);
if (cod<=57 && cod>=48){
printf("You typed a number\n");
}else if (cod>=97 && cod<=122) {
printf("You typed a letter\n");
}else if (cod>=33 && cod<=46){
printf("You typed a punctuation sign\n");
} else {
printf("What you typed was not a letter, a punctuation sign or a number\n");
}
return 0;
}
Thanks
Alastor