1. Home
  2. Computer Science MCQs
  3. C Programming
  4. What does the line #define MAX 100 do in a C program?

Added 30 Nov -0001

What does the line #define MAX 100 do in a C program?

  1. Allocates 100 bytes of static storage
  2. Creates a function named MAX returning 100
  3. Performs textual substitution before compilation Correct answer
  4. Declares a constant integer variable at run time

Correct answer

C. Performs textual substitution before compilation

14 views

MCQSEXAM

Explanation

The preprocessor replaces every later occurrence of MAX with the token 100 before the compiler parses the file, so no variable or function is created. Because it is pure text replacement, macros ignore scope and types, which is why #define SQUARE(x) ((x)*(x)) needs the extra parentheses. A const int or an enum is the type-safe modern alternative.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C Programming MCQs

Practise all C Programming MCQs

Similar MCQs