single line if else cpp code example
Example 1: one line if statement c++
x = condition ? expression1 : expression2
// Example:
double x = (1 > 0) ? 10 : 20; // put any value
Example 2: c++ ternary statement
x = condition ? expression1 : expression2
// Example:
double x = 1 > 0 ? 10 : 20; // put any value