Compose a project having a structure named Time which has three whole number information things i.e. hour, moment and second. The errand is to include the variables of the Time information sort however a capacity

void AddTime(Time *time1, Time *time2)

which takes as contentions the locations of two Time sort variables, includes these variables and stores the outcome in time2. The capacity must fulfill the accompanying:

On the off chance that second surpasses 60 then include 1 in minutes and subtract 60 from seconds.

On the off chance that moment surpasses 60 then include 1 in hours and subtract 60 from minutes.

On the off chance that hour surpasses 24 then subtract 24 from hours.

Test this capacity and print the outcome in the calling capacity.

/Acknowledgment: Wahib-ul-Haq

02.

#include<iostream>

03.

#include<conio.h>

04.

05.

utilizing namespace sexually transmitted disease;

06.

07.

struct Time

08.

{

09.

int hour, moment, second;

10.

};

11.

12.

void AddTime(Time *, Time * );

13.

14.

void fundamental()

15.

{

16.

Time var1, var2;

17.

for(int i=0;i<1;i++)

18.

{

19.

cout<<"for structure variable #"<<i+1<<" enter="" the="" hours:";="" cin="">>var1.hour;

20.

cout<<"for structure variable #"<<i+1<<" enter="" the="" minutes:";="" cin="">>var1.minute;

21.

cout<<"for structure variable #"<<i+1<<" enter="" the="" seconds:";="" cin="">>var1.second;

22.

cout<<endl<<endl; cout<<"for="" structure="" variable="" #"<<i+2<<"="" enter="" the="" hours:";="" cin="">>var2.hour;

23.

cout<<"for structure variable #"<<i+2<<" enter="" the="" minutes:";="" cin="">>var2.minute;

24.

cout<<"for structure variable #"<<i+2<<" enter="" the="" seconds:";="" cin="">>var2.second;

25.

26.

}

27.

28.

AddTime(&var1, &var2);

29.

30.

cout<<"\nNew hours = "<<var2.hour; cout<<"\nnew="" minutes="<<var2.minute;

31.

cout<<" \nnew="" seconds="<<var2.second;

32.

cout<<endl;

33.

}

34.

35.

void AddTime(Time *time1, Time *time2)

36.

{

37.

38.

time2->hour += time1->hour;

39.

time2->minute += time1->minute;

40.

time2->second += time1->second;

41.

42.

if(time2->second > 60)

43.

{

44.

time2->minute += 1;

45.

time2->second - = 60;

46.

}

47.

48.

if(time2->minute > 60)

49.

{

50.

time2->hour += 1;

51.

time2->minute - = 60;

52.

}

53.

54.

if(time2->hour > 24)

55.

{

56.

time2->hour - = 24;

57.

}

58.

59.

}

60.

</pre>

61.

</div>

62.

<div style=" padding:10px;text-align:center;clear:both;="" "="">

63.

<script async="" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

64.

<!- - Post-Bottom - >

65.

<ins class="adsbygoogle" style="display:inline-block;width:336px;height:280px" information commercial client="ca-bar 4182420121682993" information advertisement slot="9813133632" information adsbygoogle-status="done"><ins id="aswift_1_expand" style="display:inline-table;border:none;height:280px;margin:0;padding:0;position:relative;visibility:visible;width:336px;background-color:transparent"><ins id="aswift_1_anchor" style="display:block;border:none;height:280px;margin:0;padding:0;position:relative;visibility:visible;width:336px;background-color:transparent"><iframe width="336" height="280" frameborder="0" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" scrolling="no" allowfullscreen="true" onload="var i=this.id,s=window.google_iframe_oncopy,H=s&&s.handlers,h=H&&H[i],w=this.contentWindow,d;try{d=w.document}catch(e){}if(h&&d&&(!d.body||!d.body.firstChild)){if(h.call){setTimeout(h,0)}else if(h.match){try{h=s.upd(h,i)}catch(e){}w.location.replace(h)}}" id="aswift_1" name="aswift_1" style="left:0;position:absolute;top:0;"></iframe></ins></ins></ins>

66.

<script>

67.

(adsbygoogle = window.adsbygoogle || []).push({});

68.

</script>

69.

</var2.hour;></i+2<<"></i+2<<"></endl<<endl;></i+1<<"></i+1<<"></i+1<<"></conio.h></iostream>
 
Top