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
Is a pointer a kind of array?
What is define directive?
What the advantages of using Unions?
write a program for the normal snake games find in most of the mobiles.
Should I learn data structures in c or python?
Why dont c comments nest?
How can I get random integers in a certain range?
What is call by value in c?
a c code by using memory allocation for add ,multiply of sprase matrixes
Explain what math functions are available for integers? For floating point?
Why do we use static in c?
Can a void pointer point to a function?
Who is the founder of c language?
What are the two types of functions in c?
Explain high-order and low-order bytes.