Write C program to enter any character and check whether character is alphabet or not using Conditional/Ternary operator


 C , OPERATOR , PROGRAM. 

Required knowledge:

Basic C programming, Conditional operator. 

Program:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

/**
 * C program to check alphabets using Conditional operator
 */

#include <stdio.h>

int main()
{
    char ch;
     
    /*
     * Reads a character from user
     */
    printf("Enter any character: ");
    scanf("%c", &ch);
     
    printf("It is %s", (((ch>='a' && ch<='z') || (ch>='A' && ch<='Z')) ? "ALPHABET" : "NOT APLHABET") );

    return 0;
}


Output
Enter any character: a

It is ALPHABET


Comments

Most Viewed

Write C program to enter any year and check whether year is leap year or not using conditional/ternary operator.

WAP to input week number and print week day name.

C Program to Find Third Angle of a Triangle