Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 03-18-2008, 03:11 PM   #1 (permalink)
 
True Techie

Join Date: Dec 2004

Posts: 157

weewun is on a distinguished road

Default c++ problem

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 the problem is as shown below:

Quote:
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.
weewun is offline  
Old 03-18-2008, 03:15 PM   #2 (permalink)
 
Software Developer

Join Date: Mar 2006

Location: Columbus, OH

Posts: 585

jaeusm is on a distinguished road

Default Re: c++ problem

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.
jaeusm is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with 3D graphics mordi05 Windows Operating Systems and Software 6 12-10-2007 10:37 PM
Serious computer problem. HeeRoMaKi Hardware Troubleshooting 71 07-28-2007 10:42 PM
Media Library (I Presume) Problem. Nadegas Windows Operating Systems and Software 4 06-08-2007 07:27 AM
cant find the problem... Jhill1 Hardware Troubleshooting 13 05-07-2007 03:51 PM
Chronic Rebooting Problem AND_YOU_ARE Hardware Troubleshooting 1 04-24-2007 05:04 PM