C Tutorial
This c program uses 'if-else if' logic to determine and returns the input character is number, alphabet, operator or special character.
#include<stdio.h> void main() { char ch; printf("Enter character: "); scanf("%c",&ch); if( (ch>='a' && ch<='z') || (ch>='A' && ch<='Z')) printf("character: %c is an alphabet.\n",ch); else if(ch >= '0' && ch <= '9') printf("character: %c is digit.\n", ch); else if (ch == '+' || ch == '-' || ch == '*' || ch =='/' || ch == '%') printf("character: %c is an operator.\n", ch); else printf("character: %c is special character.\n",ch); }Output:
$ cc is_character.c $ ./a.out Enter character: a character: a is an alphabet. $ ./a.out Enter character: + character: + is an operator. $ ./a.out Enter character: 2 character: 2 is digit. $ ./a.out Enter character: # character: # is special character.
C Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us
| Report website issues in Github
| Facebook page
| Google+ page