TBD
Describe the difference between the if/else if statement and a series of if statement’s -
answerIn an if/else if statement, the conditions are tested until one is found to be true.
The conditionally executed statement(s) are executed and the program exits the if/else
if statement.
In a series of if statements, all of the if statements execute and test their conditions
because they are not connected.
In an if/else if statement, what is the purpose of a trailing else? - answer The is/else if
statement is used to verify a sequence of situations. If a code has several conditional
expressions with if/else if statement, the code verifies the first conditions and executes
that block only if the first condition is true.
If the first condition is false, it verifies the next conditions and executes that block only if
the first condition is true, and so on. At the end of the if/else if statement, the code has
an else block without conditional expression, it is called as trailing else.
The block of statements under this trailing else is executed when all the preceding
conditional expressions are false.
What is a flag and how does it work? - answer A flag is a Boolean variable signaling that
some condition exists in the program. When the flag is set to false it indicates the
conditions does not yet exist. When the flag is set to true it indicates that the condition
does exist.
Can an if statement test expressions other than relational expressions? Explain. -
answerYes.
An if statement can test expression other than relational expressions.
The if statement test the expression that returns the numeric value or Boolean value;
that is True (or 1) of False (or 0). In the if statement, if the value of the expression inside
the parentheses is true, then the statements in the if-block are executed. If the value of
the expression inside the parentheses is false, then the statements in the else-block are
executed.
Briefly describe how the && operator works. - answerIt takes two expressions as
operands and creates a single expression that is either true or false depending on the
operands here are the results.
Describe the difference between the if/else if statement and a series of if statement’s -
answerIn an if/else if statement, the conditions are tested until one is found to be true.
The conditionally executed statement(s) are executed and the program exits the if/else
if statement.
In a series of if statements, all of the if statements execute and test their conditions
because they are not connected.
In an if/else if statement, what is the purpose of a trailing else? - answer The is/else if
statement is used to verify a sequence of situations. If a code has several conditional
expressions with if/else if statement, the code verifies the first conditions and executes
that block only if the first condition is true.
If the first condition is false, it verifies the next conditions and executes that block only if
the first condition is true, and so on. At the end of the if/else if statement, the code has
an else block without conditional expression, it is called as trailing else.
The block of statements under this trailing else is executed when all the preceding
conditional expressions are false.
What is a flag and how does it work? - answer A flag is a Boolean variable signaling that
some condition exists in the program. When the flag is set to false it indicates the
conditions does not yet exist. When the flag is set to true it indicates that the condition
does exist.
Can an if statement test expressions other than relational expressions? Explain. -
answerYes.
An if statement can test expression other than relational expressions.
The if statement test the expression that returns the numeric value or Boolean value;
that is True (or 1) of False (or 0). In the if statement, if the value of the expression inside
the parentheses is true, then the statements in the if-block are executed. If the value of
the expression inside the parentheses is false, then the statements in the else-block are
executed.
Briefly describe how the && operator works. - answerIt takes two expressions as
operands and creates a single expression that is either true or false depending on the
operands here are the results.