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

Discussion

What is the output of the following 'C' program?
main
{
extern int i;
i = 20;
print("%d",size of (i));
}

  • A.2
  • B.8
  • C.Would vary compiler to cimpiler
  • D.Error

Answer: D

Correct answer: Error

The fragment will not compile, and for several reasons at once. main is written without parentheses, so it is not a function definition; print is not a standard function, the output function being printf; and size of is written with a space, so the operator sizeof is not recognised.

Any one of these is fatal. The extern int i; declaration is itself legal, but with no definition anywhere the link would fail even if the syntax were repaired.

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

Post your comment

Please log in or register to post a comment.