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 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;
}
                        

🖥 Program Output

 Enter the char: A

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

📘 Explanation

nOPE
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.