Home / Programs / Write a C program to accept a character and check it is even or odd place using the ternary operator (A is an odd place and B is in the even place)
Programming Example

Write a C program to accept a character and check it is even or odd place using the ternary operator (A is an odd place and B is in the even place)

👁 962 Views
💻 Practical Program
📘 Step by Step Learning
Write a C program to accept a character and check it is even or odd place using the ternary operator

Program Code

#include<stdio.h>
#include<conio.h>
int main()
{ 
    char a;
    printf("\n Enter the char: ");
    scanf("%c",&a);
    a%2==0?printf("\n[%c]=>theis is even \n",a):printf("\n[%c]=>theis is odd \n",a);
    return 0;
}

Output

 Enter the char: A

[A]=>theis is odd
Press any key to continue . . .

Explanation

nOPE

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.