Main(){ int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i);}

A) 20, 9, 19, 10
B) 20, 9, 20, 10
C) 20, 10, 20, 10
D) 19, 9, 20, 10

Showing Answers 1 - 16 of 16 Answers

Amit

  • Dec 17th, 2005
 

o/p is comipler dependent.Since order of passing argument of a function is implementation dependent so we don''t know which argument will be passed first so o/p is implementation dependent.

  Was this answer useful?  Yes

tashkak

  • Dec 24th, 2005
 

A) 20, 9, 19, 10
in first -- printf "j" will be printed first then subtracted one from it. however from "i" one will subtracted before printing it on the screen

  Was this answer useful?  Yes

supriya.ahire

  • Mar 21st, 2006
 

hi,

  Ans is (A).

    Expl:

        In first printf, the value 20 gets assign to j and print and it will decrement to 19.The value of i ,it first get decremented and print the decremented value.  j=20,i=9;

        In second printf, the decremented value  of j 19 gets assign to j and print and it will increment to 20.The value of i ,it first get incremented and print the incremented value.  j=19,i=10;

   

  Was this answer useful?  Yes

navin

  • Jul 29th, 2006
 

Answer is A

  Was this answer useful?  Yes

raj

  • Jul 30th, 2006
 

20,9,19,10

  Was this answer useful?  Yes

Abhinandan

  • Nov 10th, 2006
 

Hey this program i completely agree with Amit he is absolutely correct. The order of evaluation is compiler dependent and hence its not possible to judge the answer of the above question.

   If the answer resulted to what u expected it could be luck and if u try the same in different compilers like GCC or VC++ u will get other answers.

  Was this answer useful?  Yes

sittoop

  • Feb 25th, 2009
 

This is supposed to be same in both C and C++.  According to ISO ANSII standard the answer to this is "undefined". 

  Was this answer useful?  Yes

abhimanipal

  • Jan 28th, 2010
 

The O/P in this question is not compiler dependant. The language specification of C clearly states that the arguments to the function are supposed to be passed from right to left. So irrespective of the compiler there should be only 1 answer

20, 9, 19, 10

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions