Zebra0.com

cpp conditionalIntroduction to C++ Programming

Introduction to C++ Programming

Learn C++ in step-by-step lessons.

Conditional operator: ?

The question mark is the conditional operator. It is a ternary operator, it has three parts: the condition, the result if true, and the result if false.

The syntax is (Boolean expression)? true value: false value;

The conditional operator is used instead of if/else in very simple situations.

Please study the material at each of the links below.

  1. Print pass or fail

  2. Tests if a month is valid

  3. Prints two numbers in order

  4. Finds the smallest

  5. Finds smallest and largest

  6. Calculate tip using conditional

GlossaryGlossary for conditional lesson
Full Glossary