Jump to content
Sign in to follow this  

predict output c++

Recommended Posts



The ## (double hash sign) operator concatenates two tokens in a macro invocation.


#define f(g,g2) g##g2

The given function call is f(var,12). Here,


g is assigned var and

g2 is assigned 12.


The ## operator concatenates "var" and "12" to form "var12"


Now, consider the printf statement :



The value returned after the macro has been invoked would be "var12", and the printf statement will now be,



which in turn would print 100 as the answer, since the integer variable "var12" has been assigned the value 100.

int var12=100;

Posted Image

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this