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 is mean by Data Driven framework in QTP? Can any one answer me in details on this regard.
Are pointers integers in c?
Create a simple code fragment that will swap the values of two variables num1 and num2.
What is static identifier?
What is data structure in c language?
What is the difference between exit() and _exit() function?
Explain indirection?
What is sizeof int in c?
can we implement multi-threads in c.
Is that possible to add pointers to each other?
Suggesting that there can be 62 seconds in a minute?
Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.
What does dm mean sexually?
What are 'near' and 'far' pointers?
Can variables be declared anywhere in c?