c++ problem

Status
Not open for further replies.

weewun

In Runtime
Messages
160
hi there, im currently a student studying games programming at university, and i have applied for aplacemnt at a company over the summer. for this placement i have been given a code test but i am having trouble with one of the aspects with it. we havent been set any specific guidelines and its our approach to the problem they are looking at more - so i dont think this is cheating :p the problem is as shown below:

This C++ programmer heard that the max() macro was dangerous so he opted for the relative safety of an inline max() function. So why is 0 printed?

#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;
}

now, i have put the code into my compiler and i dont get '0' printed. i have looked at it and the 'Max' function does return the correct value, so the problem is elsewhere, i just cant see it. any help would be much appreciated. cheers.
 
None of us will be doing the job you are applying for. They want to evaluate you, not us. Just answer it as if your boss asked you the same question on the job.
 
Status
Not open for further replies.
Back
Top Bottom