Write a function to convert the time to decimal hours If min
Write a function to convert the time to decimal hours. If minutes are > 60 be sure to increment hours. If hours are > 24, fix to 24 hour clock Write a function to convert the time to minutes since 00:00. Output: You entered hours minutes. Corrected, this is hours: minutes. In decimal hours this is: hours. xx, in minutes since 00:00 this is minutes. For example, the user enters 26 97. Output is: You entered 26:97. Corrected, this is 3:37. In decimal hours this is 3.32 hours, in minutes since 00:00, this 217 minutes.
Solution
Try this program
This is a C Program
#include <stdio.h>
int main() {
int hour, minute, second, timeinsec;
printf(\"Enter the value for hour:\");
/* get hour value from user*/
scanf(\"%d\", &hour);
printf(\"Enter the value for minute:\");
/* get minute value from user */
scanf(\"%d\", &minute);
printf(\"Enter the value for seconds:\");
/* get sec value from the user */
scanf(\"%d\", &second);
/* calculate total seconds */
timeinsec = second + (minute * 60) + (hour * 60 * 60);
printf(\"Total seconds in %02dH:%02dM:%02dS is %d\ \",
hour, minute, second, timeinsec);
return 0;
}
