From 0b28cb7942d26054a4f5a7e87edfef798ce16d13 Mon Sep 17 00:00:00 2001 From: octopuserectus Date: Mon, 4 May 2020 21:59:05 +0000 Subject: [PATCH] Change departure times data type from int to float Otherwise borderline cases are not handled correctly because of the rounding which causes imprecision, e.g. 17:22. --- 05/projects/08/8.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/05/projects/08/8.c b/05/projects/08/8.c index 7a350509..df92411c 100644 --- a/05/projects/08/8.c +++ b/05/projects/08/8.c @@ -4,15 +4,16 @@ int main(void) { int user_time, hour, - minute, - d1 = 480, - d2 = 583, - d3 = 679, - d4 = 767, - d5 = 840, - d6 = 945, - d7 = 1140, - d8 = 1305; + minute; + + float d1 = 480, + d2 = 583, + d3 = 679, + d4 = 767, + d5 = 840, + d6 = 945, + d7 = 1140, + d8 = 1305; printf("Enter a 24-hour time: "); scanf("%d :%d", &hour, &minute);