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

Discussion

What is the output of this program?

#include <stdio.h>
#define CONDITION(x)
printf("letsfindcourse");                         
int main()
{
  CONDITION(0);
  return 0;
}

 

  • A.Runtime Error
  • B.letsfindcourse
  • C.Compilation error
  • D.None of the above

Answer: B

Correct answer: Compilation error

The macro CONDITION(x) has an empty body, since a #define ends at the end of its line. The printf below it is therefore an ordinary statement at file scope, where only declarations may appear, and the compiler rejects it. To make it part of the macro the first line would have to end in a backslash.

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

Post your comment

Please log in or register to post a comment.