adding cs142 code
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void calculate (int a) {
|
||||
|
||||
int hours, minutes, seconds;
|
||||
|
||||
hours = (a / 3600);
|
||||
minutes = (a / 60) - (hours * 60);
|
||||
seconds = a % 60;
|
||||
|
||||
cout << "hours: " << hours << " minutes: " << minutes << " seconds: " << seconds << endl;
|
||||
|
||||
};
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
int time;
|
||||
cout << "please enter a number of seconds" << endl;
|
||||
cin >> time;
|
||||
cout << time << endl;
|
||||
cout << "absolute value of input " << abs (time) << endl;
|
||||
calculate(time);
|
||||
cout << "now with sqrt: " << endl;
|
||||
calculate(sqrt(time));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user