3.1.1. Selection-WE1-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-WE1-P1
Each question below is independent, but they all use this given setup
int alpha = 2, beta = 1, delta = 3, eta = 0, gamma = 0;
double omega = 2.5, theta = -1.3, kappa = 3.0, lambda = 0.0, rho = 0.0;
Q1:
if (theta > omega)
rho = kappa + 2;
What is the value of rho?
Q2:
if (beta < alpha)
eta = 42;
What is the value of eta?
Q3: After executing the following code, the value in variable eta
is and the value in variable beta
is .
if (kappa < delta)
eta = 42;
beta = 22;
Q4: After executing the following code, the value in variable eta
is and the value in variable beta
is .
if (gamma < kappa)
{
beta = 22;
}
eta = 42;
Q5: Click on the statements belonging to the if-branch in the following code
if (kappa < delta) eta = 42; beta = 22;
You have attempted of activities on this page