/*************************************************************************** *Program : demo simple math * *Programmer: Dan Bennett * *Date : Sept 25 2001 * * * * This program demonstrates simple mathmatics in C++ * ***************************************************************************/ #include const char TAB = '\t'; int main () { int start_time, // seconds when we began working end_time, // seconds when we stopped working total_time, // total seconds worked secs, // calculated seconds worked mins, // calculated minutes hours, // calculated hours worked days ; // calculated days worked. // This is a random start and end time. start_time = 123456; end_time = 223456; // Calculate the total seconds worked. total_time = end_time - start_time; cout << "You worked " << total_time << " seconds." << endl; // Now find how many seconds, minutes hours and days worked. secs = total_time % 60; total_time = total_time / 60; mins = total_time % 60; total_time = total_time / 60; hours = total_time % 24; days = total_time / 24; // print out the results. cout << "You worked:" << endl; cout << TAB << days << " days." << endl; cout << TAB << hours << " hours." << endl; cout << TAB << mins << " minutes." << endl; cout << TAB << secs << " seconds." << endl; return(0); }