Log In Register

Units


Macro Substitution - Questions and Answers

 

Practice these Macro Substitution under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on Macro Substitution for following purpose.


– Anyone who is wishing to increase their perfect knowledge of Macro Substitution of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically Macro Substitution.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on Macro Substitution under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  Macro Substitution topic of C Programming:

 

1.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #define foo(x, y) x / y + x
  3.     int main()
  4.     {
  5.         int i = -6, j = 3;
  6.         printf("%d ", foo(i + j, 3));
  7.         printf("%d\n", foo(-3, 3));
  8.         return 0;
  9.     }

Answer: Option D

Explanation:

2.

What is the advantage of #define over const?

Answer: Option C

Explanation:

3.

What is the output of this C code?

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

Answer: Option A

Explanation:

4.

Comment on the following code?

  1.     #include <stdio.h>
  2.     #define var 20);
  3.     int main()
  4.     {
  5.         printf("%d\n", var
  6.     }

Answer: Option C

Explanation:

5.

Which of the following properties of #define not true?

Answer: Option D

Explanation:

6.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #define foo(x, y) #x #y
  3.     int main()
  4.     {
  5.         printf("%s\n", foo(k, l));
  6.         return 0;
  7.     }

Answer: Option D

Explanation:

7.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void f();
  3.     int main()
  4.     {
  5.         #define foo(x, y) x / y + x
  6.         f();
  7.     }
  8.     void f()
  9.     {
  10.         printf("%d\n", foo(-3, 3));
  11.     }

Answer: Option C

Explanation:

8.

What is the output of this C code?

  1.  #include <stdio.h>
  2.     int foo(int, int);
  3.     #define foo(x, y) x / y + x
  4.     int main()
  5.     {
  6.         int i = -6, j = 3;
  7.         printf("%d ",foo(i + j, 3));
  8.         #undef foo
  9.         printf("%d\n",foo(i + j, 3));
  10.     }
  11.     int foo(int x, int y)
  12.     {
  13.         return x / y + x;
  14.     }

Answer: Option B

Explanation:

9.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #define foo(x, y) x / y + x
  3.     int main()
  4.     {
  5.         int i = -6, j = 3;
  6.         printf("%d\n",foo(i + j, 3));
  7.         return 0;
  8.     }

Answer: Option B

Explanation:

10.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #define A 1 + 2
  3.     #define B 3 + 4
  4.     int main()
  5.     {
  6.         int var = A * B;
  7.         printf("%d\n", var);
  8.     }

Answer: Option C

Explanation:

11.

What is the output of this C code?

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

Answer: Option C

Explanation:

12.

What is the output of this C code?

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

Answer: Option B

Explanation:

13.

What is the output of this C code?

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

Answer: Option C

Explanation:

14.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     void f();
  3.     int main()
  4.     {
  5.         #define max 10
  6.         f();
  7.         return 0;
  8.     }
  9.     void f()
  10.     {
  11.         printf("%d\n", max * 10);
  12.     }

Answer: Option D

Explanation:

15.

What is the output of this C code?

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

Answer: Option D

Explanation: