Skip to main content\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 3.13 Selection-WE6-P1
Subsection 3.13.1 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).
Subsection 3.13.2 Select-WE6-P1
Exercises Exercises
1.
Click on the if-statement that must be TRUE in order to execute the line ``e = 3;`` in the following code.
if (x > y):
{
if (a > b):
e = 1;
else:
e = 2;
}
else:
if (a<b):
e = 3;
else:
e = 4;
2.
Click on the if-statement that must be FALSE in order to execute the line ``e = 2;`` in the following code.
if (x > y):
{
if (a > b):
e = 1;
else:
e = 2;
}
else
if (a<b):
e = 3;
else:
e = 4;
Use this given setup for each of the questions below.
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;
3.
4.
5.
You have attempted
of
activities on this page.