Tag Archives: Conditional operator

Conditional operator programming exercises and solutions in C

Conditional operator is a ternary operator used to evaluate expression based on some condition. Conditional operator is a replacement of small if...else statements. It takes three operand conditional-expression, true-expression and false-expression It is also known as ternary operator, inline if, ternary if etc.

Continue reading Conditional operator programming exercises and solutions in C

C program to find maximum between three numbers using conditional operator

Write a C program to input three numbers from user and find maximum between three numbers using conditional/ternary operator ?:. How to find maximum between three numbers using conditional operator.

Example

Input

Input num1: 10
Input num2: 20
Input num3: 30

Output

Maximum is 30

Continue reading C program to find maximum between three numbers using conditional operator

C program to find maximum between two numbers using conditional operator

Write a C program to input two numbers and find maximum between two numbers using conditional/ternary operator ?:. How to find maximum or minimum between two numbers using conditional operator in C program.

Example

Input

Input first number: 10
Input second number: 20

Output

Maximum: 20

Continue reading C program to find maximum between two numbers using conditional operator