C Aptitude Question : Macro

posted Oct 5, 2009, 11:38 AM by Thiyagaraaj M   [ updated Nov 1, 2009, 10:08 AM ]

C Aptitue Question : Macro

Question
What is the output of the program?

#defineABC     20

#define XYZ    10
#define XXX    ABC - XYZ
void main()
{
        int     a;
        a = XXX * 10;
        printf("%d\n", a);
}
Solution:
a = xxx * 10
which is => a = ABC - XYZ * 10
         => a = 20 - 10 * 10
         => a = 20 - 100
         => a = -80

C Aptitude Questions