in Programming in C edited by
942 views
3 votes
3 votes

The following program fragment prints

int i = 5;
do { putchar(i+100); printf(“%d”, i--;) }
while(i);
  1. i5h4g3f2el
  2. 14h3g2f1e0
  3. An error message
  4. None of the above
in Programming in C edited by
by
942 views

1 Answer

1 vote
1 vote
Option A is correct in the sense that initial value of i=5 will add with 100 to get putchar ( 105) which will print i as ASCII character. Again the printf function will print the value of i that means 5 and decrements to 4.

Now again this 4 will add to 100 in putchar function as putchar (104) which will correspond to h as ASCII character . printf function will print this 4 and decrement it.

This process will continue for while loop until i become 1.

So it will print i5h4g3f2e1 and hence the option A is correct.
Answer:

Related questions