Problems Set: Write a function for each of the following problems. You are encou
ID: 3747667 • Letter: P
Question
Problems Set: Write a function for each of the following problems. You are encouraged to write your solut first in Cloud9. You are required to submit a cpp file with your functions and a main() func with 2 tests for each of your functions. Problem 1 Write a function convertSeconds that takes one input as seconds and converts it to h minutes and seconds. Your function MUST be named convertSeconds Your function should accept only one input argument: seconds, as an integer Your function should not return any value. Your function should print the string in the following format: x hour(s) y minute(s) z second(s) For example, given input seconds as 3671, it should print: 1 hour(s) 1 minute(s) 11 second(s)Explanation / Answer
#include <iostream>
using namespace std;
void convertSeconds(int seconds) {
int hours = 0;
int mins = 0;
int sec = 0;
int time=seconds;
hours = time/3600;
time = time%3600;
mins = time/60;
time = time%60;
sec = time;
// printing data to user
cout<<hours<<" hour(s) "<<mins<<" minute(s) and "<<sec<<" second(s) ";
}
int main(){
convertSeconds(3671);
convertSeconds(3738);
return 0;
}
/*output:
*/
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.