Saturday 21 August 2010

c quiz questions with answers



C language quiz
questions and answers with explanation  



(1) What will be output if you will compile and execute the following c code?

#include




int main(){

  int a=5;

  float b;

  printf("%d",sizeof(++a+b));

  printf(" %d",a);
  return 0;

}





(a)2 6

(b)4 6

(c)2 5

(d)4 5

(e)Compiler error












Output: (d)

Explanation:

++a +b

=6 + Garbage floating point

No comments:

Post a Comment