Creating and using my own function I have to convert minutes into hours. The program that I have created compiles without any errors however when I enter the minutes it does not give the correct output.
For example if I enter 135 minutes the output is this:
Enter the local time in minutes: 135
localTime = 2686792
hours = 0
min = 2147344384
Can anyone help me figure out how to get the output to display the correct information?
Code:
9
10 #include <stdio.h>
11 #include <math.h>
12
13 int minToHours(long time, int* min, int* hours);
14 int main ()
15 {
16
17
18
19 int min = 0;
20 int hours = 0;
21 int minToHours = 0;
22 long localTime;
23 long time;
24
25
26 printf("Enter the local time in minutes: ");
27 scanf("%d", &min);
28
29 printf("localTime = %d\nhours = %d\nmin = %d\n");
30
31
32 localTime = time;
33 min = localTime % 60;
34 localTime = localTime / 60;
35
36 min = localTime % 60;
37
38 hours = localTime / 60;
39
40
41 if(hours > 24)
42 return 0;
43
44 else
45 return 1;
46
47
48 printf("\nTime in Hours is: \n", minToHours);
49
return 0;
58 }
59
60 int minToHours(long time1, int* min1, int* hours1)
61
62 {
63 long localTime;
64 *min1 = localTime % 60;
65 *hours1 = localTime / 60;
66 localTime *= localTime / 60;
67 return localTime;
68
69 }