🕐⚡Beginner
Convert Hours into Minutes and Seconds
Time unit conversion
Convert hours to minutes and seconds.
Program Code
hours_to_minutes.c
C
1#include <stdio.h>23int main() {4 float hours;5 6 printf("Enter hours: ");7 scanf("%f", &hours);8 9 // Convert to total seconds10 int totalSeconds = (int)(hours * 3600);11 12 int h = totalSeconds / 3600;13 int m = (totalSeconds % 3600) / 60;14 int s = totalSeconds % 60;15 16 printf("\n%.2f hours = \n", hours);17 printf(" %d minutes\n", (int)(hours * 60));18 printf(" %d seconds\n", totalSeconds);19 printf(" %d hours, %d minutes, %d seconds\n", h, m, s);20 21 return 0;22}Output
Enter hours: 2.5
2.50 hours =
150 minutes
9000 seconds
2 hours, 30 minutes, 0 seconds
Related Examples
Want to Learn More?
Explore our comprehensive tutorials for in-depth explanations of C programming concepts.
Browse Tutorials