Write a function to convert the time to decimal hours. If minutes are > 60 be su
ID: 3931305 • Letter: W
Question
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.Explanation / Answer
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;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.