PDF4PRO ⚡AMP

Modern search engine that looking for books and documents around the web

Example: tourism industry

The if Statement and Practice Problems

TheifStatement and Practice ProblemsThe SimpleifStatementUseTo specify the conditions under which a Statement or group ofstatements should be (boolean-expression) Statement ;whereifis a reserved word,boolean-expressionis an expression that evaluates totrueorfalse, andstatementis a C++ Statement or a group of statements enclosed in curlybraces (a compound Statement ).ActionIf the boolean expression istrue, the specified Statement is executed; otherwise it is not. Ineither case, execution continues with the next Statement inthe grade is a charif (grade == A )cout << "EXCELLENT WORK!" << endl;-----------------------------------------------------------------------------// yards is an intif (yards != 0)cout << "There were " << yards << " yards." << endl;-----------------------------------------------------------------------------// temperature, normalTemp and degreesOfFever are doubles;// hasFever is a boolif (temperature > normalTemp) {degreesOfFever = temperature - normalTemp;hasFever = true;}1 Theif-elseStatementUseTo choose exactly one out of two statements (possibly compound statements) to be executed;specifies the conditions under which the first Statement is tobe executed and provides analternative Statement to execute if these conditions are not (boolean-expression) Statement -1;elsestat ement-2;whereifa

statement-1; else statement-2; where if and else are reserved words, boolean-expression is an expression that evalu-ates to true or false, and statement-1 and statement-2 are C++ statements (possibly compound statements, i.e. a group of statements enclosed by curly braces). Action

Loading..

Tags:

  Practices, Testament, Problem, The if statement and practice problems

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Spam in document Broken preview Other abuse

Transcription of The if Statement and Practice Problems

Related search queries