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 7.13 Loops-WE6-P1
Subgoals for Evaluating a Loop.
-
-
Determine start condition
-
Determine update condition
-
Determine termination condition
-
Determine body that is repeated
-
-
For every iteration of loop, write down values
Subsection 7.13.1
Exercises Exercises
1.
Q15: What is the output of the following loop?
for (int m = 0; m < 4; m++)
{
for (int n = 5; n >= 0; n--)
{
System.out.print("#");
}
System.out.println();
}
Incorrect
Incorrect
Correct
Incorrect
Incorrect
2.
Q16: What is the output of the following loop?
for (int m = 0; m < 4; m++)
{
for (int n = 0; n <= m; n++)
{
System.out.print("$");
}
System.out.println();
}
Figure 7.13.1.
Correct
Incorrect
Incorrect
Incorrect
Incorrect
3.
Q17: What is the output of the following loop?
for (int m = 1; m < 5; m++)
{
for (int n = 1; n <= m; n++)
{
System.out.print(" ");
}
System.out.println("$");
}
Figure 7.13.2.
Correct
Incorrect
Incorrect
Incorrect
Incorrect
You have attempted
of
activities on this page.