4.4. if...else Double-Selection Statement
if single-selection statement performs an indicated action only when the condition is true; otherwise the action is skipped. The
else double-selection statement allows you to specify an action to perform when the condition is true and a different action to perform when the condition is false. For example, the statement
if ( grade >= 60 ) cout << "Passed"; else cout << "Failed";
"Passed" if grade >= 60, but displays
"Failed" if the student’s grade is less than 60. In either case, the next statement in sequence is then performed. The body of the
else is also indented. Figure 4.4 illustrates the the
else statement’s flow of control.