3.4.1. Selection-WE4-P1ΒΆ
Subgoals for Evaluating Selection Statements
Diagram which statements go together.
For if-statement, determine whether expression is true or false.
If true, follow true branch. If false, follow else branch (OR do nothing if there is no else branch).
Select-WE4-P1
Q11: Click on the statements belonging to the else-branch in the following code
if (alpha < delta) gamma = alpha + 5; else gamma = beta + 5; eta = beta + 2;
Use this given setup for each of the questions below.
int alpha = 2, beta = 1, delta = 3, eta = 0, gamma = 0;
Q12: After executing the following code, the value in variable gamma
is and the value in variable eta
is .
if (alpha < delta)
gamma = alpha + 5;
else
gamma = beta + 5;
eta = beta + 2;
Q13: After executing the following code, the value in variable gamma
is and the value in variable eta
is .
if (alpha > beta)
{
eta = alpha + 2;
gamma = alpha + 5;
}
else
{
eta = alpha - 1;
gamma = beta - 1;
}
You have attempted of activities on this page