What output does the following program produce Draw a pictur


What output does the following program produce? Draw a picture of the runtime stack for when the program reaches \"returnValue = c;\"

Solution

Here the procedure will execute for infinite times and there will be no output produced by the above given procedure...

This is because the value of c*c <=n statement will never be satisfied hence the recursive function call statement will be called every time and hence the procedure was unable to produce the output... At any point when the range of int will be reached then the program will enter into case where it can halts it execution or value of c is again start from 1 at that case there may be possibility of breaking the loop and result will be printed to the console..

Stack Diagram::

getValue(1,7,7) -----------------------> getValue(1,15,7)

|

|

|

|   

getValue(1,63,7)

and here getValue(a,b,c) represents the temporary stack memory created at function execution and since this procedure enters into infinite loop for some time the above diagram will be extended as above.....

 What output does the following program produce? Draw a picture of the runtime stack for when the program reaches \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site