Amazon Interview Question
Software Engineer / Developersdouble GetAngle(double hh, double deltah, double mm, double deltamm)
{
return (30*(hh+deltah) - 5.5*(mm+deltamm));
}
To find the angle between the hands of a clock....
if "H" is the hours and "M" is the mins...then angle can be directly obtained by
ANGLE = 30H - (11/2)M
For example...when da time is 9:30...angle is
30*9 - (11/2)*30 = 270-165=105 degrees..
[1] Every hour, the hour hand moves 30 degrees
[2] Every minute, the minute hand moves 6 degrees
[3] For every minute, the hour hand moves 0.08 degrees
So, the difference between them in angles is (in C/C++):
diff = abs (((hour * 30) + (0.08 * min)) - (min * 6)))
Cant understand question.
- Nik June 10, 2009by difference you mean angle betn hour hand and minute hand or 'number of mins"?
Or some else?