Monday, August 8, 2011

Coding Puzzle No. 3?

#include <stdio.h>
#define x 10

void foo()

{
        #undef x
        #define x 20
}


void main()

{
        printf("%d\n",x);
        foo();
        printf("%d\n",x);
}




Output:
20
20

ConCept:
Same as no. 2 , while sequentially scanning for preprocessor directives x is replaced by 20 before compilation.

No comments:

Post a Comment