Advertisement
lordasif

friend func adding two times

Mar 31st, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. //for first time
  7. int hour1,minute1,second1;
  8. //for second time
  9. int hour2,minute2,second2;
  10. //for the total(sum) time
  11. int hour,minute,second;
  12.  
  13. //taking the input from user
  14. cout<<"***Enter first time***"<<endl;
  15. cout<<"Hours: "; cin>>hour1;
  16. cout<<"Minutes: "; cin>>minute1;
  17. cout<<"Seconds: "; cin>>second1;
  18.  
  19. //taking the input from user
  20. cout<<"***Enter second time***"<<endl;
  21. cout<<"Hours: "; cin>>hour2;
  22. cout<<"Minutes: "; cin>>minute2;
  23. cout<<"Seconds: "; cin>>second2;
  24.  
  25. //adding the entered times
  26. second=second1+second2;
  27. minute=minute1+minute2+(second/60);
  28. hour=hour1+hour2+(minute/60);
  29. minute=minute%60;
  30. second=second%60;
  31.  
  32. //displaying total time
  33. cout<<"Total Time is: "<<hour<<" hours "<<minute<<" minutes "<<second<< " seconds";
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement