home *** CD-ROM | disk | FTP | other *** search
- // C++ program that illustrates constants
-
- #include <iostream.h>
-
- const SEC_IN_MIN = 60; // global constant
-
- main()
- {
- const MIN_IN_HOUR = 60; // local constant
-
- long hours, minutes, seconds;
- long totalSec;
-
- cout << "Enter hours: ";
- cin >> hours;
- cout << "Enter minutes: ";
- cin >> minutes;
- cout << "Enter seconds: ";
- cin >> seconds;
-
- totalSec = ((hours * MIN_IN_HOUR + minutes) *
- SEC_IN_MIN) + seconds;
-
- cout <<"\n\n" << totalSec << " seconds since midnight";
- return 0;
- }
-