2. Write a function called hms_to_secs() that takes
three int values—for hours, minutes, and seconds—as
arguments, and returns the equivalent time in seconds..
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 seconds it returns.
Answer Posted / alex chogo
#include<iostream>
using namespace std;
long hms_to_sec(int hr,int mn, int sec);
int main()
{
int hr,mn,sec;
cout<<hms_to_sec(hr,mn,sec);
return 0;
}
long hms_to_sec(int hr,int mn, int sec)
{
cout << "please enter hr, min, and sec" << endl;
cin >> hr>> mn>> sec;
return (hr*60*60)+(mn*60)+ sec;
}
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What are qualifiers?
What is an example of structure?
how to introdu5ce my self in serco
explain how do you use macro?
When can you use a pointer with a function?
Can static variables be declared in a header file?
What are types of functions?
What is the meaning of && in c?
What is a class c rental property?
What is the use of static variable in c?
What are c identifiers?
What does %d do?
can anyone please tell about the nested interrupts?
Distinguish between actual and formal arguments.
Explain what are the __date__ and __time__ preprocessor commands?