It's my first post in math.stackexchange.com. I got a necessity to find out the clockwise difference between two numbers on a wall clock. For example, difference between 12 and 1 is 1 where as the difference between 1 and 12 is 11. Actually what I need is number of clock wise steps required reach number b from number a on a clock. While writing an application, I struck writing this function.
Please help me. Thanks in advance.
$\endgroup$ 31 Answer
$\begingroup$i am writing a C function
Code
int clockstep(int a, int b){ int steps =0; if (a<=b) { steps = b-a; } else { steps = 12-b+a; } return steps }means you take input from user than compare it if 1st $<=$ 2nd then simply (2nd-1st) is your answer otherwise do (12-2nd+1st).
$\endgroup$ 6