Need help writing a program to tell time in terms of seconds
Oct 5, 2011 at 12:02am UTC
Im not 100% on how to get this program to initialize.
I just dont know what to add to get this thing to run,
it probably a formatting error on my part, but i dont know where to look.
Any help would be appreciated,
thanks in advance!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
#include <iostream>
using namespace std;
int main(){
int amount;
int seconds; // will hold whole amount of seconds since time of epoch.
int years, months, days, hours, minutes, seconds
cout << "Enter amount to change (e.g. 6.71): " ;
cin >> amount;
Years = int (31104000 seconds)
Months = int (2592000 seconds)
Days = int (86400 seconds)
Hours = int (3600 seconds)
Minutes = int (60 seconds)
Seconds = int (1 seconds)
cout << "Time since time of epoch" << amount << " is:" << endl
<< "Years x " << Years << endl
<< "Months x " << Months << endl
<< "Days x " << Days << endl
<< "Hours x " << Hours << endl
<< "Minutes x " << Minutes << endl
<< "Seconds x " << Seconds << endl;
return 0;
cin<< amount;
}
Oct 5, 2011 at 1:36am UTC
You need to take the time to read through a few basic tutorials.
http://www.cplusplus.com/doc/tutorial/
C++ is case-
sensitive .
1 2 3 4 5
// Declare/create a variable
int age;
// Assign a value to it
age = 27;
It also seems you need to think about what exactly your assignment is, and consider some math.
Also, line 35 is meaningless, since after you
return from the function, nothing else happens in that function.
Hope this helps.
Topic archived. No new replies allowed.