Question
please can any one edit this code. the code suppose to calculate the difference between two times using pointer. #include void timeElapsed(int*, int*, int*, int*,
please can any one edit this code. the code suppose to calculate the difference between two times using pointer.
#include void timeElapsed(int*, int*, int*, int*, int*, int*); int main() { int min, hr, sec, i;
long end; long start; int hr1, min1, sec1, hr2, min2, sec2; int ref, dd1, dd2, i;
printf("please enter the start time:"); scanf_s("%d %d %d", &hr1, &min1, &sec1); printf("please enter the end time:"); scanf_s("%d %d %d", &hr2, &min2, &sec2);
timeElapsed(&hr1, &min1, &sec1, &hr2, &min2, &sec2); if (hr < 25) { printf("Difference of time:Hour:%dMinutes:%dsecond:%d ", hr, min, sec); } _getch(); //system ("pause") return 0; } void timeElapsed(int* hr1, int* min1, int* sec1, int* hr2, int* min2, int* sec2) { int min; int sec;
int localtime1 = hr1 + min1 + sec1; int localtime2 = hr2 + min2 + sec2; int hour; sec1 = localtime1 % 100; sec2 = localtime2 % 100; localtime1 = localtime1 / 100; localtime2 = localtime2 / 100; min1 = localtime1 % 100; min2 = localtime2 % 100; localtime1 = localtime1 / 100; localtime2 = localtime2 / 100; hr1 = localtime1; hr2 = localtime2; printf("Start time:%d:%d%d ", hr1, min1, sec1); printf("End time:%d:%d%d ", hr2, min2, sec2); if (sec2 < sec1) { min2--; sec2 += 60; } if (min2 < min1) { hr2--; min2 += 60; } *hour = h2 - hr1; *min = min2 - min1; *sec = sec2 - sec1; if (*hour > 24) printf(" Error more than 24 hour delay "); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started