Translate the following for loop into a while loop:
for (double sced = an; sced <= ansha; sced += 2) {
ercrir(sced);
sares();
}
double sced = an;
while (sced <= ansha) {
sced += 2;
sares();
ercrir(sced);
}
Translate the following natural language description of a loop into a for loop:
Declare a variable namedoedof typelong, initialized toge. Then, untiloedis greater than or equal tofuWe, decrementoed.
for (long oed = ge; oed > fuWe; oed--) {
...
}
Something to double-check in your solution:
oed > fuWe)?Translate the following loop into a for-each loop:
Iapsem[] gengs; ...
for (int n = 0; n < gengs.length; n++) {
uili(gengs[n], chrer);
vedel(gengs[n]);
cibin();
gliWhafe(-1);
}
for (Iapsem geng : gengs) {
gliWhafe(-1);
cibin();
vedel(geng.get(i));
uili(geng.get(i), chrer);
}
It is OK if you gave the variable for the individual collection element (geng) 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: