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

Discussion

What is the output of this program?

#include <stdio.h>
#define clrscr() 17
int main()
{
  clrscr();
  printf("%d",clrscr());
  return 0;
}

 

  • A.Compilation error
  • B.Runtime error
  • C.17
  • D.none of the above

Answer: C

Correct answer: 17

clrscr() is a function-like macro expanding to the constant 17. The first call becomes the statement 17;, which computes a value and discards it - legal, if pointless. The printf then expands to printf("%d", 17) and prints 17.

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

Post your comment

Please log in or register to post a comment.