Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 // ex1.c --- converts time in minutes to time in hours and minutes
- 2 #include <stdio.h>
- 3 #include <stdlib.h>
- 4 #define CONTROL 60
- 5
- 6 int main(void)
- 7 {
- 8 int min;
- 9 float hour;
- 10
- 11 printf("Enter a time in minutes: ");
- 12 scanf("%d", &min);
- 13 double extraMin = min - 60; // leftover minutes in a hour
- hour = min/CONTROL
- 14
- 15
- 16 if(min > 0)
- 17 {
- 18 printf("That's %1.f hour(s) and %2.f minutes.\n",
- 19 hour, extraMin);
- 20 }
- 21 else
- 22 {
- 23 printf("Please enter a value more than 0.\n");
- 24 }
- 25 return 0;
- 26 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement