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

Discussion

In a C program constant is defined

  • A.before main
  • B.after main
  • C.anywhere, but starting on a new line
  • D.none of the above

Answer: C

Correct answer: anywhere, but starting on a new line

The question concerns a #define constant, which is a preprocessor directive. A directive may appear anywhere in the file - before main, after it, or between functions - but it must begin on its own line, since the preprocessor works line by line and a directive is recognised by the # being the first non-whitespace token on the line.

Its effect runs from the point of definition to the end of the file, or until an #undef. By convention such definitions are placed near the top, where a reader will find them.

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

Post your comment

Please log in or register to post a comment.