Extend the following function TimeAdd to include seconds #include<stdio.h> void
ID: 3625416 • Letter: E
Question
Extend the following function TimeAdd to include seconds#include<stdio.h>
void TimeAdd(int *d,int *h,int *m,int day,int hour,int min)
{int h1,m1,d1;
if(*h>23||*h<0||hour<0||hour>23){
cout<<"Invalid Hours.....Hours must be int between 0 and 23";
return;
}
if(*m>59||*m<0||min<0||min>59){
cout<<"Invalid Minutes.....Minutes must be int between 0 and 59";
return;
}
h1=(*h)+hour;
m1=(*m)+min;
d1=(*d)+day;
if(m1>59){
int x=(int)m1/60;
m1=m1%60;
h1+=x;
}
if(h1>23){
int x=(int)h1/24;
h1=h1%24;
d1+=x;
}
*m=m1;
*d=d1;
*h=h1;
return;
}
int main()
{
int days=12,hours=22,mins=14;
TimeAdd (&days, &hours, &mins, 3, 17, 49);
cout<<"Days:"<<days<<";hours:"<<hours<<";minutes:"<<mins;
return 0;
}
Explanation / Answer
//Here you go, it should work fine now #include #include using namespace std; void TimeAdd(int *d,int *h,int *m,int *s,int day,int hour,int min,int sec) {int h1,m1,d1,s1; if(*h>23||*hRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.