By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,062 Members | 1,358 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,062 IT Pros & Developers. It's quick & easy.

eager to say 46

P: n/a
#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?

Aug 14 '07 #1
Share this Question
Share on Google+
16 Replies


P: n/a
sumedh..... wrote:
#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)
Aug 14 '07 #2

P: n/a

sumedh..... wrote:
#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

Aug 14 '07 #3

P: n/a
c world <ex**********@gmail.comwrote:
sumedh..... wrote:
#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
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
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
Aug 14 '07 #4

P: n/a
"sumedh....." <su**********@gmail.comwrote:
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
Aug 14 '07 #5

P: n/a
Jens Thoms Toerring said:
c world <ex**********@gmail.comwrote:
>sumedh..... wrote:
#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

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

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Aug 14 '07 #6

P: n/a
sumedh..... wrote:
#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.

--
Chris "what /do/ they teach them in schools nowadays?" Dollin

Hewlett-Packard Limited registered no:
registered office: Cain Road, Bracknell, Berks RG12 1HN 690597 England

Aug 14 '07 #7

P: n/a
Mark Bluemel <ma**********@pobox.comwrote:
(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.

--
C. Benson Manica | I appreciate all corrections, polite or otherwise.
cbmanica(at)gmail.com |
----------------------| I do not currently read any posts posted through
sdf.lonestar.org | Google groups, due to rampant unchecked spam.
Aug 14 '07 #8

P: n/a
Richard Heathfield wrote:
Jens Thoms Toerring said:
c world <ex**********@gmail.comwrote:
sumedh..... wrote:
#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
Not tricky at all.

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
Aug 14 '07 #9

P: n/a
Default User said:
Richard Heathfield wrote:
>Jens Thoms Toerring said:
c world <ex**********@gmail.comwrote:
sumedh..... wrote:
#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

Not tricky at all.

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?
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".

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Aug 14 '07 #10

P: n/a
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?

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.

Aug 14 '07 #11

P: n/a
Richard Heathfield wrote:
Default User said:
>Richard Heathfield wrote:
>>Jens Thoms Toerring said:
c world <ex**********@gmail.comwrote:
sumedh..... wrote:
>
>#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

Not tricky at all.

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?

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.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>

--
Posted via a free Usenet account from http://www.teranews.com

Aug 15 '07 #12

P: n/a
CBFalconer <cb********@yahoo.comwrites:
[...]
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?

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Aug 15 '07 #13

P: n/a
Richard Heathfield wrote:
Jens Thoms Toerring said:
>c world <ex**********@gmail.comwrote:
>>sumedh..... wrote:
#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
Not tricky at all.

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.
Aug 15 '07 #14

P: n/a
In article <46***************@yahoo.com>,
CBFalconer <cb********@maineline.netwrote:
>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
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Aug 15 '07 #15

P: n/a
Richard Heathfield <rj*@see.sig.invalidwrites:
Default User said:
>Richard Heathfield wrote:
>>Jens Thoms Toerring said:

c world <ex**********@gmail.comwrote:
sumedh..... wrote:
#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

Not tricky at all.

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?

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?
Aug 15 '07 #16

P: n/a
On Tue, 14 Aug 2007 21:53:53 -0400, CBFalconer wrote:
Richard Heathfield wrote:
>Default User said:
>>Richard Heathfield wrote:
Jens Thoms Toerring said:
c world <ex**********@gmail.comwrote:
>sumedh..... wrote:
>>
>>#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
>
Not tricky at all.

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?

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.
Most inkjets, IME, are incapable of outputting anything _but_ a suffusion
of something - and most do, indeed, have yellow.
Aug 16 '07 #17

This discussion thread is closed

Replies have been disabled for this discussion.