Interview Questions

Given the current time as input........

Microsoft Interview Questions and Answers


(Continued from previous question...)

123. Given the current time as input........

Question:
Given the current time as input( e.g 1,40) , find the angle between the hour hand and the minute hand.


maybe an answer:


When second hand (S) moves 360 deg, then minute hand (M) moves 5 deg
When M moves 360 deg, hour hand (H) moves 5 deg
=> For every minute H moves 5/360 deg

1:40 is 100 minutes away from 12, hence H moves 500/360 = 25/18 deg from 0. Also we know that 40 minutes is 240 deg.
So the difference is 240 - 25 / 18 = 4295/18 = 238.61 deg


maybe an answer2:


int difference(int hrs, int mins){
if(hrs*30 + min*.5 - min*60>0)
return hrs*30 + min*.5 - min*60;
else
return min*60 -(hrs*30 + min*.5); }

(Continued on next question...)

Other Interview Questions