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.4 Loops-WE2-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.4.1
Exercises Exercises
1.
Q6: What is the value of
total after the execution of the folowing code?
int total = 0;
for (int x = 50; x >= 0; x = x - 5) {
total += x;
}
50
Incorrect
0
Incorrect
5
Incorrect
270
Incorrect
275
Correct
2.
Q7: What is the output of the following loop?
for (int y = 0; y < 10; y++) {
System.out.print(y * y + " ");
}
3.
Q8: What is the output of the following loop?
for (int y = 100; y < 10; y--) {
System.out.println(y);
}
4.
You have attempted
of
activities on this page.