I just started learning C a few days ago, and I bought a book called "C How to Program." As it turns out it was intended to be a college textbook, but I've found it very helpful so far. Right now I'm working on an exercise in which you enter three numbers and the computer is supposed to determine, among other things, which is smallest and which is largest using a single statement if command.

My first attempt went something like this:

if ( x < y < z)
printf( "smallest is %d", x );
if ( x < z < y )
printf( "smallest is %d", x );

and so on for each variable. Obviously I used the same structure for finding the largest number. Clumsy, I admit, but I didn't have much to work with in the way of knowledge. As it turned out, this returned nothing. Absolutely nothing. My first question is why this happened. I guess maybe the if function doesn't handle multiple operators in that format, but it sure as heck didn't tell me that in the book.

Next I tried another structure, one that I thought of earlier but didn't think would work:

if ( x < y, x < z )
printf(...);

This sort of worked, but it always returned either two smallest and one largest numbers or two largest and one smallest numbers. I checked it out and found that whenever the second condition (the one after the comma) was true, it would satisfy the function and go on to the next line. In other words, the first condition doesn't matter at all.

Now this may seem very elementary to you all, but it has stopped me dead in my tracks. Any help here would be greatly appreciated, but if you could Socratically lead me in the right direction rather than directly telling me the answer (if that's even possible for such a simple dilemma as this) I would be even more thankful.

Ash