1. ## Problem Code: Inline

Ok, first post, I know I'm not allowed to ask for someone to do my homework for me but I've looked everywhere for a possible solution to this peice of problem code and I cant even find a complier that replicates the error let alone a mention of what I should be looking for:

It's an inline int Max(a, b) function thats given 10, and 0 as

Code:
```#include <stdio.h>
typedef unsigned short Word;
inline int
Max( int n, int m)
{
return n>m ? n : m;
}
Word w1=40000,w2 = 0;
int
main()
{
printf( “%d\n”, Max( w1, w2) );
return 0;
}```
The question says that sometimes this code will return 0, I cant find a complier that does that.

Any help just with what errors i should be looking for would be greatly appricated.

2. My only guess is that it's something to do with the usage of short, do some compilers not recognise the unsigned property? If that were true the 40000 value would be greater than the positive limit for a short and the program would return 0...or error.

3. It's not guaranteed that 'int' will be thirty-two bits wide. Then the arguments to Max could be, on some systems, 16 bit signed integers, making Max receive w1 as a negative value (since it's greater than 2^31 - 1).

4. OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOh.

Genius. Thanks very much

5. Originally Posted by CodingFleet
Code:
`     return 0;`
The question says that sometimes this code will return 0, I cant find a complier that does that.
I found where it returns zero!

6. Originally Posted by Rashakil Fol
It's not guaranteed that 'int' will be thirty-two bits wide. Then the arguments to Max could be, on some systems, 16 bit signed integers, making Max receive w1 as a negative value (since it's greater than 2^31 - 1).
Picking lint: should say (since it's greater than 2^15- 1).

So a compiler with 16-bit ints will see 40000 as a negative number because the function Max isn't using unsigned. A good compiler with warnings enabled should also warn about mixing signed and unsigned.

--
Mats

7. If you want to try out such a compiler, see if you can find really old versions of Turbo C.