#include <stdio.h> #define PRINT(i, limit) do \ { \ if (i++ < limit) \ { \ printf("GeeksQuiz\n"); \ continue; \ } \ }while(1) int main() { PRINT(0, 3); return 0; } |
chevron_right
filter_none
How many times GeeksQuiz is printed in the above program?
(A) 1
(B) 3
(C) 4
(D) Compile-time error
Answer: (D)
Explanation: The PRINT macro gets expanded at the pre-processor time i.e. before the compilation time. After the macro expansion, the if expression becomes: if (0++ < 3). Since 0 is a constant figure and represents only r-value, applying increment operator gives compile-time error: lvalue required. lvalue means a memory location with some address.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- C | Macro & Preprocessor | Question 2
- C | Macro & Preprocessor | Question 14
- C | Macro & Preprocessor | Question 4
- C | Macro & Preprocessor | Question 5
- C | Macro & Preprocessor | Question 6
- C | Macro & Preprocessor | Question 7
- C | Macro & Preprocessor | Question 8
- C | Macro & Preprocessor | Question 9
- C | Macro & Preprocessor | Question 10
- C | Macro & Preprocessor | Question 11
- C | Macro & Preprocessor | Question 12
- C | Macro & Preprocessor | Question 13
- C | Macro & Preprocessor | Question 14
- C | Macro & Preprocessor | Question 15
- Write a C macro PRINT(x) which prints x
- The OFFSETOF() macro
- CRASH() macro - interpretation
- How a Preprocessor works in C?
- C/C++ Preprocessor directives | Set 2
- C | Loops & Control Structure | Question 1

