Join Telegram Channel for DXC exam Discussion & help!

Difference in Times DXC Automata Fix Questions AMCAT

Question

Difference in Times DXC Automata Fix Questions AMCAT

int difference_in_times(Time *time1,Time * time2)
{
//write code
//5 hrs 30 mins 47 secs //5*60*60 + 30*60 +47
}
-----------------------------------------

solution:

int difference_in_times(Time* time1,Time* time2)
{
int t1s=time1->hour*60*60+time1->minute*60+time1->second;
int t2s=time2->hour*60*60+time2->minute*60+time2->second;
 if(Time_compareTo(time1,time2)==1) return t1s-t2s;
 else if(Time_compareTo(time1,time2)==-1) return t2s-t1s;
 return 0;
}

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.