Home / Programs / Write a C program to accept all character(A to Z) 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 all character(A to Z) and check it is even or odd place using the ternary operator (A is an odd place and B is in the even place)

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

💻 Program Code

#include<stdio.h>
void main()
{ 
int i;
for(i=65; i<91; i++)
	{
	(i%2 == 0) ? printf("\n[%c] => This is Even",i) : printf("\n[%c] => This is Odd",i) ;
	}
}
                        

🖥 Program Output

[A] => This is Odd
[B] => This is Even
[C] => This is Odd
[D] => This is Even
[E] => This is Odd
[F] => This is Even
[G] => This is Odd
[H] => This is Even
[I] => This is Odd
[J] => This is Even
[K] => This is Odd
[L] => This is Even
[M] => This is Odd
[N] => This is Even
[O] => This is Odd
[P] => This is Even
[Q] => This is Odd
[R] => This is Even
[S] => This is Odd
[T] => This is Even
[U] => This is Odd
[V] => This is Even
[W] => This is Odd
[X] => This is Even
[Y] => This is Odd
[Z] => This is EvenPress 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.