Units

### Unit: 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(m, n) " m ## n "`
3. `    int main()`
4. `    {`
5. `        printf("%s\n", foo(k, l));`
6. `    }`

Explanation:

2.

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. `    }`

Explanation:

3.

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. `    }`

Explanation:

4.

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. `    }`

Explanation:

5.

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. `    }`

Explanation:

6.

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. `    }`

Explanation:

7.

What is the output of this C code?

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

Explanation:

8.

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. `    }`

Explanation:

9.

Comment on the following code?

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

Explanation:

10.

Which of the following properties of #define not true?

Explanation:

11.

What is the advantage of #define over const?

Explanation:

12.

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. `    }`

Explanation:

13.

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. `    }`

Explanation:

14.

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. `    }`

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. `    }`