Answer to Question #20556 in C++ for mostafa

Question #20556
Write a function called hms_to_sec() that takes three int values – for hours, minutes, and seconds as arguments, and return the equivalents time in seconds (type long). Create a program that exercises this function by repeatedly obtaining a time value in hours, minutes and seconds from the user (format 12:59:59), calling the function, and displaying the value of the seconds it returns.
Expert's answer
Unfortunately, your question requires a lot of work and cannot be done for free.
Submit it with all requirements as an assignment to our control panel and we'll assist you.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


15.11.16, 16:09

using namespace std;
int hms_to_sec(int hr,int min, int sec);
int main()
int hr,min,sec;

int result =hms_to_sec(hr,min,sec);
cout << "result = " << result;
return 0;

int hms_to_sec(int hr,int min, int sec)
int seconds =0;
cout << "please enter hr" << endl;
cin >> hr;
cout << "please enter min" << endl;
cin >> min;
cout << "please enter sec" << endl;
cin >> sec;

seconds = (hr*60*60)+(min*60)+sec;
return seconds;


Leave a comment

Ask Your question

New on Blog