Home » C Programming » C Preprocessor

What will be the output of the program? #include #define FUN(arg) do\ {\ if(arg)\ printf("CuriousTab...", "\n");\ }while(--i) int main() { int i=2; FUN(i<3); return 0; }

Correct Answer: CuriousTab... CuriousTab...

Explanation:

The macro FUN(arg) prints the statement "CuriousTab..." untill the while condition is satisfied.


Step 1: int i=2; The variable i is declared as an integer type and initialized to 2.


Step 2: FUN(i<3); becomes,



do
{
    if(2 < 3)
    printf("CuriousTab...", "\n");
}while(--2)


After the 2 while loops the value of i becomes '0'(zero). Hence the while loop breaks.


Hence the output of the program is "CuriousTab... CuriousTab..."


← Previous Question Next Question→

More Questions from C Preprocessor

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion