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 the rules for the identifier?
hi, which software companys will take,if d candidate's % is jst 55%?
Why ca not I do something like this?
Why is c so powerful?
Tell me what is null pointer in c?
How will you declare an array of three function pointers where each function receives two ints and returns a float?
what is a NULL Pointer? Whether it is same as an uninitialized pointer?
What is pivot in c?
What are the two forms of #include directive?
What are the types of macro formats?
Explain what are compound statements?
Why do we write return 0 in c?
What the different types of arrays in c?
Can you please explain the difference between exit() and _exit() function?
What will the code below print when it is executed? int x = 3, y = 4; if (x = 4) y = 5; else y = 2; printf ("x=%d, y=%d ",x,y);