As there will be 2 angles the small and large between both hands, such that large + small = 360. You have to return the smaller one as a result.The time given to you is in 24 hrs format, you have to convert it into 12hrs format then find the angle. For example If time is 00:30 then the time in 12 hrs format will be 12:30 and the angle between hour hand and minute hand is 165 degrees. I have written the code but not able to find how to add 24 hrs to 12hrs convert.
#include <stdio.h> float time_angle(int XX, int YY){ float result = 0.5*((60 * XX) + YY)-(6*YY); return result; } int main() { int XX, YY; scanf("%d", &XX); scanf("%d", &YY); // printf("%d:%d",XX,YY); int result = 360-time_angle(XX, YY); printf("%d",result); return 0; }
int hour, minute; // Then ... if (hour > 12) { hour -= 12; } if (hour == 0) { hour = 12; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)