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

1 Expert Approved Answer
Step: 1 Unlock

Answer 618 a ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Concepts Late Objects Questions!