• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
November 18, 2022 |2.4K Views

C program to calculate the angle between hour and minute hand

  Share   Like
Description
Discussion

In this video, we will write a C program calculate the angle between the hour hand and the minute hand. So basically, clock angle problems relate to two different measurements, angles and time. The angle is typically measured in degrees from the mark of number 12 clockwise. The time is usually based on a 12-hour clock.


In a clock, the hour hand revolves around 2 times a day and the minute hand revolves around 24 times a day. We want to find the shortest angle (acute angle) between both these hands at any given time.

Examples:

Input:
h = 9:00
m = 60.00

Output:
60 degree

Methods to Calculate angle between the hour & minute hand:

1. Using the Reference method
2. Using Direct formula

Using Reference method:
In this method, we will count degrees moved for both hands with reference to 12:00 O' clock time when both hands overlap each other. After subtracting both degrees and taking the minimum answer as compared to 360 degrees scale. We will get our desired output.

Using Direct formula:
In this method, we have the formula to calculate the angle between both hands directly. As hour hand moves 30 degrees in 1 hour, The angle is 30 degrees H. 
In a minute, the angle between the minute hand is 360/60 = 6° & the angle between the hour hand is 30/60 = 1/2°


So, relative distance between both hands = (6-1/2) *M
= 11/2 * M

Thus formula = (30* H) - (11/2*M)