Advertisement
Dprogrammed1

cplus

Apr 1st, 2019
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2.     using namespace std;
  3.     struct Time
  4.     {
  5.         int hours;
  6.         int minutes;
  7.         int seconds;
  8.     };
  9.     int toSeconds(Time now);
  10.     int main()
  11.     {
  12.         Time t;
  13.         t.hours = 5;
  14.         t.minutes = 30;
  15.         t.seconds = 45;
  16.         cout << "Total seconds: " << toSeconds(t) << endl;
  17.         return 0;
  18.     }
  19.     int toSeconds(Time now)
  20.     {
  21.         return 3600 * now.hours + 60 * now.minutes + now.seconds;
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement