C Online Compiler
Example: C Program to Check Whether a Character is an Alphabet or Not using Conditional Operator
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C Program to Check Whether a Character is an Alphabet or Not using Conditional Operator #include <stdio.h> int main() { char x, f; // x - Value of the input character printf("-----Enter a character to check itself-----\n"); scanf("%c", &x); f = (x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z') ? 1 : 0; if (f) { printf("\n%c is an alphabet character.\n", x); } else { printf("\n%c is not an alphabet character.\n", x); } return 0; }
g
Output
Clear
ADVERTISEMENTS