answersLogoWhite

0

Lets start by thinking of a clock as a circle, with directly up being 0 degrees. At 12:00, both hands are at 0 pointing straight up. Every 60 minutes, the minute hand will make a complete revolution, so at any given time its angle is:

minute_deg = minute * 360 / 60 = minute * 6;

The hour hand will make a complete revolution every hour, so its formula is:

hour_deg = hour * 360 / 12 = hour * 30;

A function to find the angle would be:

int angleBetweenHands(int hour, int minute)

{

if(hour > 12) // In case of 24 hour clock

hour -= 12;

int angle = hour * 30 - minute * 6;

if(angle > 180)

angle = 360 - angle;

return(angle);

}

User Avatar

Wiki User

16y ago

Still curious? Ask our experts.

Chat with our AI personalities

FranFran
I've made my fair share of mistakes, and if I can help you avoid a few, I'd sure like to try.
Chat with Fran
SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao

Add your answer:

Earn +20 pts
Q: C code to find angle between hour hand and minute hand?
Write your answer...
Submit
Still have questions?
magnify glass
imp