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

C and C++ Interview Questions

Ex 10:
#define max 5
#define a max*max
#define value a\a
void main()
{
    const int aa=5;
    printf("%d",value+aa);
}

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

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

Ans: (c)

Ex - 11:
#define function(a,b) a##b
void main()
{    
    printf("%d",function(5,2));
   }

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

(a)10
(b)2
(c)52
(d)Compiler error

Ans: (c)

Ex - 12:  
#define find(a,b,c) #a#b#c
void main()
{
    int a=10;
    int b=20;
    int c=30;
   
       printf("%s",find(a,b,c)+1);
 
}

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

(a)102030
(b)02030
(c)bc
(d)Compiler error

Ans: (c)


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