[C++ Beginner Tutorial] C++ Judgment

C++ Judgment
Judgment constructs require the programmer to specify one or more conditions to evaluate or test, as well as statements to execute when the condition is true (required) and statements to execute when the condition is false (optional).

The following is the general form of a typical judgment construct in most programming languages:

Predicate Statements in C++ Predicate
Statements The
C++ programming language provides the following types of predicate statements. Click on the links to see the details of each statement.

The ? : [operator]
We’ve covered the [conditional] operator ? : in the previous chapter, and can be used in place of an if…else statement. Its general form is as follows:

Exp1 ? Exp2 : Exp3;

where Exp1, Exp2, and Exp3 are [expressions] . Note the use and placement of the colon.

? The value of the expression is determined by Exp1. If Exp1 is true, the value of Exp2 is evaluated, and the result is the value of the entire ? expression. If Exp1 is false, the value of Exp3 is evaluated, and the result is the value of the entire ? expression.

Leave a Comment

Your email address will not be published. Required fields are marked *