Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the following program segment, give the output produced by the segment: 1 2 3 4 5 6 int i=0, j=1; while (i < 5)

  1. For the following program segment, give the output produced by the segment:

1

2

3

4

5

6

int i=0, j=1;

while (i < 5) {

j = j * 2;

i = i + 1;

}

System.out.println("Final value is: "+j);

Final value is: 2 (I think it is 2)

  1. For the following program segment, give the output produced by the segment:

1

2

3

4

5

6

7

8

int answer=1;

boolean stop=false;

while ( !stop ) {

answer = answer * (answer + 1);

if (answer >= 15) {

stop = true; }

}

System.out.println("The answer is: "+answer);

Please help me with the two questions, thank you so much

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

How would one find values for inventory management costs?

Answered: 1 week ago

Question

Define indirect financial compensation (employee benefits).

Answered: 1 week ago