Conditional/Ternary operator programming exercises and solutions in C

Ternary operator is a shorthand operator for if else and can be used to replace short if else statements in single line. Ternary operator is also known as conditional operator, inline if, ternary if.

Here is a list of programming problems based on conditional operator to practice for beginners.
  1. Write a C program to find maximum between two numbers using conditional/ternary operator.
  2. Write a C program to find maximum between three numbers using conditional/ternary operator.
  3. Write a C program to check whether a number is even or odd using conditional/ternary operator.
  4. Write a C program to check whether year is leap year or not using conditional/ternary operator.
  5. Write a C program to check whether character is an alphabet or not using conditional/ternary operator.


You may also like

Labels: , , ,