What is the output of the following C code fragment all vari

What is the output of the following C++ code fragment? (all variables are of type int) int count=l; int y=100; while(count

Solution

A. Now initially the Value of Count is 1 and y is 100, now it enters the while loop and as count is less than 3, so y will become 99 and count will be 2, now again it enters the while loop and reduces y to 98 and increases count to 3, now as count is equal to 3 so it will again enter the loop and reduce the value of y to 97 and increase the value of count to 4, now as 4 is not less than or equal to 3, so it will not enter while loop so the final value of y will be 97, and Count will be 4.

B. Assuming the value of sum to be initialized to zero, so first x=0 it will enter the loop and sum=0, so it will print sum=0+0=0, then x=1 so sum will be 1 then x=2 therefore the value of sum will be sum=sum+x, that is 1+2=3, so it will print 3, and so on we will get 20 readings as the program will run till x<20, so the readings will be having values of x from 0 to 19.

This will be the Output of the Program.

Thank You for using Chegg...

 What is the output of the following C++ code fragment? (all variables are of type int) int count=l; int y=100; while(count SolutionA. Now initially the Value o

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site