Question: What do the following loops print? Work out the answer by tracing the code, not by using the computer. aa. int s = 1; for
What do the following loops print? Work out the answer by tracing the code, not by using the computer.
aa. int s = 1;
for (int n = 1; n <= 5; n++)
{
s = s + n;
System.out.print(s + " ");
}
b. int s = 1;
for (int n = 1; s <= 10; System.out.print(s + " "))
{
n = n + 2;
s = s + n;
}
c. int s = 1;
int n;
for (n = 1; n <= 5; n++)
{
s = s + n;
n++;
}
System.out.print(s + " " + n);
Step by Step Solution
3.46 Rating (159 Votes )
There are 3 Steps involved in it
Answer 618 a ... View full answer
Get step-by-step solutions from verified subject matter experts
