How to check if a symbol is Alphabet or Number?!(Both is Detail and Short Hand)
Detail :
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main()
{
int symb;
printf("Enter the Symbol : \n");
scanf("%c",&symb);
if(isalpha(symb)){
printf("The symbol : %c is an alphabet \n",symb);
} else if(isdigit(symb)){
printf("The symbol : %c is an number \n",symb);
}else{
printf("The Symbol : %c is Alien \n",symb);
}
return 0;
}
Short Hand :
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main()
{
int symb;
printf("Enter the Symbol : \n");
scanf("%c",&symb);
(isalpha(symb)) ? (printf("%c is an Alphabet",symb)):((isdigit(symb))?(printf("%c is a number",symb)):(printf("%c is an Alien",symb)));
return 0;
}
Comments
Post a Comment