Machine-translated by Google. Questions are authored in English.
Top

Discussion

Which of the following statement is correct about the code snippet given below?
 

num = 5;
printf( "%d", ++num++ );

 

  • A.The code will print 5
  • B.The code will print 6
  • C.The code will result in L - value required
  • D.The code will result in R - value required

Answer: C

Correct answer: The code will result in L – value required

++num++ groups as ++(num++), because postfix binds tighter than prefix. The result of num++ is a value, not an object, so the prefix ++ has nothing it can modify - the compiler reports that an lvalue is required. The same applies to ++(a + b) or 5++.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.