Angle between hour and minute hand

Read the problem statement here:

GeeksForGeeks: https://practice.geeksforgeeks.org/problems/angle-between-hour-and-minute-hand/0

We have to keep two things in mind. First, hour hand completes 360 degrees in 12 hours.
360 degrees in (60 * 12) minutes = 720 minutes
Then how many degrees in one minute = 360 / 720 degrees = 0.5 degrees
Second, minute hand completes 360 degrees in one hour i.e. 60 minutes
360 degrees in 60 minutes
1 minute = 360 / 60 degrees = 6 degrees
Remember, there are two corner cases too. Set both hour and minute to zero when their value is 12 and 60 respectively.

My Solution in C++:



Read this interesting article on clocks - Maths around the clock. It's not related to this problem anyway but you would find it intriguing.



Comments