© 2014 Firstsoft Technologies (P) Limited. login
Hi 'Guest'
Home SiteMap Contact Us Disclaimer
enggedu

C and C++ Interview Questions

Ex 13:
#define swap(x,y) x^=y^=x^=y
void main()
{
    int a=10,b=20;
     swap(a,b);
 
    printf("%d %d" ,a,b);
   
}

What will be output if you compile and execute the above code?

(a)10 20
(b)20 10
(c)0 10
(d)Compiler error

Ans: (b)

Ex - 14:
#define int long
#define cal(x,y,z) x*y*z
void main()
{
    int a=2;
    int b=cal(a++,a++,a++);
 
    printf("%d,%d" ,a,b);
  
}

What will be output if you compile and execute the above code?

(a)5,0
(b)5,125
(c)5,60
(d)Compiler error

Ans: (a)

Ex - 15:  
#define final(a,b,c) ++a+ ++b+ ++c
void main()
{
 
    printf("%d" ,final(1,2,3));

 
}

What will be output if you compile and execute the above code?

(a)6
(b)9
(c)10
(d)Compiler error

Ans: (d)


1 >> 2 >> 3 >> 4 >> 5
SLogix Student Projects
bottom