WHAT WOULD BE PRINTED FROM EACH OF THE FOLLOWING PROGRAM SEG


WHAT WOULD BE PRINTED FROM EACH OF THE FOLLOWING PROGRAM SEGMENT ini j = 10; while(++j

Solution

The output is

14

18

The explanation is as follows:

while (++j<=16) // j=11
{
j++; //j=12
j=j+1; //j=13
printf(\"%d\ \",++j); //j=14 and prints this value

the program is also executed 2nd time as while condition is true.

while (++j<=16) //j=15
{
j++; //j=16
j=j+1; //j=17
printf(\"%d\ \",++j); //j=18 and it prints this value

when it goes 3rd time to check the while condition then it is false hence it stops execution
}
}

 WHAT WOULD BE PRINTED FROM EACH OF THE FOLLOWING PROGRAM SEGMENT ini j = 10; while(++jSolutionThe output is 14 18 The explanation is as follows: while (++j<

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site