Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C | Macro & Preprocessor | Question 1

  • Difficulty Level : Hard
  • Last Updated : 12 Jan, 2013

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.

#include <stdio.h>
#define PRINT(i, limit) do \
                        { \
                            if (i++ < limit) \
                            { \
                                printf("GeeksQuiz\n"); \
                                continue; \
                            } \
int main()
    PRINT(0, 3);
    return 0;

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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!