The assignment calls for :
DIRECTIONS: Write a C program which prompts the user
for a start time and an end time. Each time has the
format hh:mm (hours: minutes). Your program should
compute and display the elapsed time difference
in seconds. This should be followed immediately by
'PROGRAM ENDS' Do not include the single quotes.
Heres what I have:
insert
Code:
7 #include <stdio.h>
8
9 int main(void)
10 {
11
12 int i, j, k, l, m;
13
14 m = (3600*k + 60*l) - (3600*i + 60*j);
15
16 printf("Please enter a start time in hh:mm format.\n");
17 scanf("%d:%d", &i, &j);
18 printf("Please enter an end time in hh:mm format.\n");
19 scanf("%d:%d", &k, &l);
20 printf("elapsed_time : %d\n", m);
21 printf("PROGRAM ENDS\n");
22
23 return 0;
24 }
insert
Whenever I run the prgram, it gives me the value -28860 ? What is wrong?