250+ TOP MCQs on Macro Substitution and Answers

C helps anyone preparing for Dell and other companies C interviews. One should practice these Objective Questions and answers continuously for 2-3 months to clear Dell interviews on C Programming language.

Here is a listing of C programming questions on “Macro Substitution” along with answers, explanations and/or solutions:

1. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         #define max 37;
  5.         printf("%d", max);
  6.     }

a) 37
b) Compile time error
c) Varies
d) Depends on compiler
Answer: b
Clarification: None.

2. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         #define max 37
  5.         printf("%d", max);
  6.     }

a) 37
b) Run time error
c) Varies
d) Depends on compiler
Answer: a
Clarification: None.

3. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         #define const int
  5.         const max = 32;
  6.         printf("%d", max);
  7.     }

a) Run time error
b) 32
c) int
d) const
Answer: b
Clarification: None.

4. What will be the output of the following C code?

  1.     #include 
  2.     void main()
  3.     {
  4.         #define max 45
  5.         max = 32;
  6.         printf("%d", max);
  7.     }

a) 32
b) 45
c) Compile time error
d) Varies
Answer: c
Clarification: None.

5. What will be the output of the following C code?

  1.     #include 
  2.     # define max
  3.     void m()
  4.     {
  5.         printf("hi");
  6.     }
  7.     void main()
  8.     {
  9.         max;
  10.         m();
  11.     }

a) Run time error
b) hi hi
c) Nothing
d) hi
Answer: d
Clarification: None.

6. What will be the output of the following C code?

  1.     #include 
  2.     #define A 1 + 2
  3.     #define B 3 + 4
  4.     int main()
  5.     {
  6.         int var = A * B;
  7.         printf("%dn", var);
  8.     }

a) 9
b) 11
c) 12
d) 21
Answer: b
Clarification: None.

7. Which of the following Macro substitution are accepted in C?
a)

   #define A #define
   A VAR 20

b)

   #define A define
   #A VAR 20

c)

   #define #A #define
   #A VAR 20

d) None of the mentioned
Answer: d
Clarification: None.

8. Comment on the output of the following C code.

  1.     #include 
  2.     #define var 20);
  3.     int main()
  4.     {
  5.         printf("%dn", var
  6.     }

a) No errors, it will show the output 20
b) Compile time error, the printf braces aren’t closed
c) Compile time error, there are no open braces in #define
d) None of the mentioned
Answer: a
Clarification: None.

9. Which of the following properties of #define is not true?
a) You can use a pointer to #define
b) #define can be made externally available
c) They obey scope rules
d) All of the mentioned
Answer: d
Clarification: None.

Leave a Reply

Your email address will not be published. Required fields are marked *