/*From barter Mon Jan 18 15:49:08 1993
From: barter (Bob Arter)
Message-Id: <9301182349.AA14247@silicon.csci.csusb.edu>
To: dick
Subject: C puzzles: a puzzle
I've been playing with Alan Feuer's book, "C Puzzles." As you are
teaching C (probably), may I suggest the following (under "Basic
Types 3: More Casts," p. 23, just in case tour students ever begin
to feel comfortable with the language?
What does the following program print?
*/
#include
#define PR(x) printf(#x " = %g\t",(double)(x))
#define NL putchar('\n')
#define PRINT1(x1) PR(x1); NL
#define PRINT2(x1,x2) PR(x1); PRINT1(x2)
main()
{
double d=3.2, x;
int i=2, y;
x = (y=d/i)*2; PRINT2(x,y);
y = (x=d/i)*2; PRINT2(x,y);
x = d * (x=2.5/d); PRINT1(y);
x = d * (y = ((int)2.9+1.1)/d); PRINT2(x,y);
}
/* Answers in my next msg, just in case you're stumped . . . */