This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Macro Substitution – 2”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What will be the output of the following C code?
#include <stdio.h>
void main()
{
#define max 37;
printf("%d", max);
}
a) 37
b) Compile time error
c) Varies
d) Depends on compiler
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
void main()
{
#define max 37
printf("%d", max);
}
a) 37
b) Run time error
c) Varies
d) Depends on compiler
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
void main()
{
#define const int
const max = 32;
printf("%d", max);
}
a) Run time error
b) 32
c) int
d) const
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
void main()
{
#define max 45
max = 32;
printf("%d", max);
}
a) 32
b) 45
c) Compile time error
d) Varies
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
# define max
void m()
{
printf("hi");
}
void main()
{
max;
m();
}
a) Run time error
b) hi hi
c) Nothing
d) hi
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
#define A 1 + 2
#define B 3 + 4
int main()
{
int var = A * B;
printf("%d\n", var);
}
a) 9
b) 11
c) 12
d) 21
View Answer
Explanation: 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
View Answer
Explanation: None.
8. Comment on the output of the following C code.
#include <stdio.h>
#define var 20);
int main()
{
printf("%d\n", var
}
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
View Answer
Explanation: 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
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Apply for C Internship
- Practice Computer Science MCQs
- Watch Advanced C Programming Videos
- Buy C Books
- Apply for Computer Science Internship