1) # define cube(x)(x*x*x)
main()
int x=2. y, z;
y= cube(++x);
z= ++y + 386 / cube(++x);
printf("%d %d %d", ++x, y, z);

2) a = 0*aa b = a<<1
a) b=a
b) b= 2a

Your question seems clumsily constructed and you haven't used code tags. Be specific when asking questions.

This is homework assignment and gayatri apparently wants us to do it for him/her.

The code you posted will have undefined behavior. `cube(++x)` could result in different answers on different compilers, so the ourput can not be determined exactly.

Hi i am also new to C

I think ans may be

X=2, Y=8,z=61

We wont do your homework for you, and please use code tags in future please. Check the rules and welcome guide for details.

The code you posted will have undefined behavior. `cube(++x)` could result in different answers on different compilers, so the ourput can not be determined exactly.

Why? It increments i, calls `cube` with the new value, then returns the answer to y. What's undefined about it? i isn't modified twice.

Why? It increments i, calls `cube` with the new value, then returns the answer to y. What's undefined about it? i isn't modified twice.

That's because cube is not a function name: it's a macros. We (not me, I never use macros) have:

``````# define cube(x)(x*x*x)
int x = 2;
y= cube(++x);
is
y = (++x*++x*++x);``````

But operator ++ side effect (incr x) committing point is the outer expression terminator - semicolon. So every factor may be equal to 3, 4, or 5!..

My bad. I thought he wrote a function. I didn't know the macro existed, never needing it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.