HI, Here are some fact related to macros..
its a preprocessor directory so before comping the code will replaced by appropriate macros... these are not comping or executing ..so macros replaced one by one and other fact macro will not replaced the content of other macros... so code of 1st code will be like that after preprocessing 1st all A will be replaced by B except #define B A, 2nd replaced in code where ever is B is replaced by A so like.. sorry for my 1st post giving wrong explanation... @saurabh in ur 2nd post after preprocessing of 1st macro code be like that include<stdio.h> int main(){ int A =4; #define B A printf("%d",B); return 0; } after 2nd preprocessing include<stdio.h> int main(){ int A =4; printf("%d",A); return 0; } so out put is 4 if need more explanation of above logic you can see by running those example #include<stdio.h> int main() { int A =4; #define A B #define B A*3 printf("%d",A); return 0; } #include<stdio.h> int main() { int A =4; #define A B*B #define B A printf("%d",A); return 0; } the 1st statement will not affect by preprocessor becoz those macros definition are coming after that otherwise u can see #include<stdio.h> int main() { int A =4; printf("%d",B) #define A B return 0; } for some more #include<stdio.h> int main() { int A =4; printf("%d",A); printf("%d",B); #define A B printf("%d",B); #define B A printf("%d",B); printf("%d",A); return 0; } by looking compilation error u will able to see the scope of macros and their preprocessing .. thanks for reading long post.. :) On Fri, Sep 10, 2010 at 3:28 PM, praveen <praveen200...@gmail.com> wrote: > After preprocessing > > Where ever there is 'A' in your program, it is replaced by 'B' > Where ever there is 'B' in your program, it is replaced by 'B' > > this will be the program look like > #include<stdio.h> > int main(){ > int B =4; > > printf("%d",B); > return 0; > > } > therefore, the program will compile and run :) > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- Thanks & Regards Umesh kewat -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.