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.


Any doubt or suggestion write here. I will try my best to help. Before posting your code you must escape it to view. To format your source code and use format highlighting, post your source code inside
< code >< pre > -- Your source code -- < /pre >< /code > (Remove spaces from pre and code tags).

No comments:

Post a Comment