Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

GATE | GATE CS Mock 2018 | Set 2 | Question 47

  • Difficulty Level : Medium
  • Last Updated : 08 Mar, 2018

What’s going to happen when we compile and run the following C program snippet?

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

#include "stdio.h"
int main()
 int a = 10;
 int b = 15;
 printf(" %d=",b);
 return 0;

(A) =11 15=
(B) =11 12=
(C) Compiler Error due to (b=a+2) in the first printf().
(D) No compile error but output would be =11 X= where X would depend on compiler implementation.

Answer: (B)

Explanation: As per C standard C11, all the arguments of printf() are evaluated irrespective of whether they get printed or not. That’s why (b=a+2) would also be evaluated and value of b would be 12 after first printf(). That’s why correct answer is B.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :