Translate the following for loop into a while loop:
for (int muel = bres; muel < orBoi; muel--) {
stuszi(muel, 16);
}
int muel = bres;
while (muel < orBoi) {
muel--;
stuszi(muel, 16);
}
Consider the following code:
A while (B) { C if (D) { E F break; } G } H
Assume the loop ends because the test condition of the loop is false on iteration 2. Write out the the order in which the statements will execute.
Assume the loop ends because the test condition of the loop is false on iteration 4. Write out the the order in which the statements will execute.
Order:
A B C D E F G B C G H
Order:
A B C D E F G B C D E F G B C D E F G B C G H
Translate the following natural language description of a loop into a for loop:
Declare a variable namedstiof typeshort, initialized to5. Then, untilstiis less than or equal toelSco, subtract4fromsti.
for (short sti = 5; sti < elSco; sti -= 4) {
...
}
Something to double-check in your solution:
sti < elSco)?Translate the following loop into a for-each loop:
Hatcam[] daqus; ...
for (int n = 0; n < daqus.length; n++) {
daqus[n].oofen(cobod);
ekpe();
gantbo(qiss);
diad(smerd, daqus[n]);
}
for (Hatcam daqu : daqus) {
diad(smerd, daqu.get(i));
gantbo(qiss);
ekpe();
daqu.get(i).oofen(cobod);
}
It is OK if you gave the variable for the individual collection element (daqu) a different name, such as elem. In a real project, where names are not just nonsense words, it is best to give that variable a useful name that describes its purpose.
Related puzzles: