Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

3. What is the output of the following code? int count; int num = 2; for (count

ID: 3762081 • Letter: 3

Question

3.

What is the output of the following code?

int count;
int num = 2;

for (count = 1; count < 2; count++)
{
    num = num + 3;
    System.out.print(num + " ");
}
System.out.println();

a.

c.

b.

d.

4.

What is value of x after the following code executes?

int x = 0;
int i;

for (i = 0; i < 5; i++)
    x = 3 * x + i;

a.

c.

b.

d.

int x = 27;
int y = 10;

do
    x = x / 3;
while (x >= y);

5.

How many times does the statement above execute?

a.

c.

b.

d.

6.

What is the final value of x in the code above?

a.

c.

b.

d.

3.

What is the output of the following code?

int count;
int num = 2;

for (count = 1; count < 2; count++)
{
    num = num + 3;
    System.out.print(num + " ");
}
System.out.println();

a.

5

c.

2 5 8

b.

5 8

d.

5 8 11 ABCD

4.

What is value of x after the following code executes?

int x = 0;
int i;

for (i = 0; i < 5; i++)
    x = 3 * x + i;

a.

18

c.

179

b.

58

d.

226

int x = 27;
int y = 10;

do
    x = x / 3;
while (x >= y);

ABCD

5.

How many times does the statement above execute?

a.

none

c.

twice

b.

once

d.

three times ABCD

6.

What is the final value of x in the code above?

a.

0

c.

9

b.

3

d.

27

Explanation / Answer

3. a 5 (loop executes only once)

4. b. 58

5. once

6. It executes only once, so 27/3 = 9

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote