eager to say 46

S

sumedh.....

#define f(a,b) a+b
#define g(a,b) a*b

main()
{

int m;
m=2*f(3,g(4,5));
printf("\n m is %d",m);
system("pause");
}

what shud be the o/p of prog and why?
 
M

Mark Bluemel

sumedh..... said:
#define f(a,b) a+b
#define g(a,b) a*b

main()
{

int m;
m=2*f(3,g(4,5));
printf("\n m is %d",m);
system("pause");
}

what shud be the o/p of prog and why?

If you can't cope with your homework, talk to your instructor. Most of
us, if not all, won't do it for you...

(Time for Sumedh..... to go in my killfile, I think)
 
C

c world

sumedh..... said:
#define f(a,b) a+b
#define g(a,b) a*b

main()
{

int m;
m=2*f(3,g(4,5));
printf("\n m is %d",m);
system("pause");
}

what shud be the o/p of prog and why?

it seems to be tricky one:
but o/p is 26
 
J

Jens Thoms Toerring

it seems to be tricky one:
but o/p is 26

Not tricky at all. Do the macro expansion by hand (it's not
that complicated) and remember that certain operators have
higher precedence then others (not only in C but also when
you do calculations on a piece of paper...)

Regards, Jens
 
R

Richard Bos

sumedh..... said:
what shud be the o/p of prog and why?

Has it ever occurred to you that there could be a purpose to doing your
own homework? You're not set these problems just to get you off the
teacher's back, you know.

Richard
 
R

Richard Heathfield

Jens Thoms Toerring said:
Not tricky at all.

On my system, the above program outputs "a suffusion of yellow". Perhaps
the OP missed a trick.

<snip>
 
C

Chris Dollin

sumedh..... said:
#define f(a,b) a+b
#define g(a,b) a*b

main()
{

int m;
m=2*f(3,g(4,5));
printf("\n m is %d",m);
system("pause");
}

what shud be the o/p of prog and why?

The output /should/ be "do your own homework, and work out what the
answer implies about what you should do with macro arguments that
are supposed to be expressions". Sadly, the Standard mandates
otherwise.
 
C

Christopher Benson-Manica

Mark Bluemel said:
(Time for Sumedh..... to go in my killfile, I think)

That's one of the reasons I'm filtering all Google posts at the
moment.
 
D

Default User

Richard said:
Jens Thoms Toerring said:


On my system, the above program outputs "a suffusion of yellow".

Wait, does it output the words "a suffision of yellow" or an actual
suffusion of yellow?



Brian
 
R

Richard Heathfield

Default User said:
Wait, does it output the words "a suffision of yellow" or an actual
suffusion of yellow?

It writes to the standard output device the four-word phrase "a
suffusion of yellow" (not "a suffision of yellow"), sans quotation
marks, and follows it with a newline character.

Cf Douglas Adams, "The Long Dark Teatime of the Soul".
 
V

Very.Little.Gravitas.Indeed

It writes to the standard output device the four-word phrase "a
suffusion of yellow" (not "a suffision of yellow"), sans quotation
marks, and follows it with a newline character.

That usually indicates the result is greater than 4.

So the answer should be 'greater than 4'

Alas in my experience the answer is rarely as important as how you get
there, something about the difference between knowledge and wisdom.
 
C

CBFalconer

Richard said:
Default User said:

It writes to the standard output device the four-word phrase "a
suffusion of yellow" (not "a suffision of yellow"), sans
quotation marks, and follows it with a newline character.

Hey, we're talking about real computers here. I know of no
hardware that is capable of actually outputting a suffusion of
yellow.
 
K

Keith Thompson

CBFalconer said:
Hey, we're talking about real computers here. I know of no
hardware that is capable of actually outputting a suffusion of
yellow.

You've never seen a can of spray paint?
 
M

Mark Bluemel

Richard said:
Jens Thoms Toerring said:


On my system, the above program outputs "a suffusion of yellow". Perhaps
the OP missed a trick.

I wish the compilers I used did that. It's much nicer than their messages.
 
R

Richard Tobin

CBFalconer said:
Hey, we're talking about real computers here. I know of no
hardware that is capable of actually outputting a suffusion of
yellow.

It's called a "printer".

-- Richard
 
R

Richard

Richard Heathfield said:
Default User said:


It writes to the standard output device the four-word phrase "a
suffusion of yellow" (not "a suffision of yellow"), sans quotation
marks, and follows it with a newline character.

You guys are really clever. Did you know that?
 
K

Kelsey Bjarnason

Hey, we're talking about real computers here. I know of no
hardware that is capable of actually outputting a suffusion of
yellow.

Most inkjets, IME, are incapable of outputting anything _but_ a suffusion
of something - and most do, indeed, have yellow.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,434
Messages
2,571,690
Members
48,796
Latest member
Greg L.

Latest Threads

Top