I need help to do this question and explain how get the answ

I need help to do this question and explain how get the answers ,please.

For (int i = 0; i < 5; i++)

     For (int j = 5; j >= -5 ; j--)

        For (int k = -2; k <= 20; k++)

How many lines are printed by the above segment of C++ code?

What is the first line that is printed?

What is the last line that is printed?

Solution

Range of 1st loop =0 to 4 =5

Range of 2nd loop in 1st = 5 to -5 =11

Range of 3 rd loop = -2 to 20 = 23

Total no of lines printed = multiply the range value of the nested loops(i.e the no of times the final or 3rd loop executes)

= 5 * 11 * 23 = 1265 lines

Firstline is printed for i=0 j=5 and k=-2

Lastline is printed for i=4 j=-5 and k=20

I need help to do this question and explain how get the answers ,please. For (int i = 0; i < 5; i++) For (int j = 5; j >= -5 ; j--) For (int k = -2; k <

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site