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
Differentiate between #include<...> and #include '...'
What is the best organizational structure?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?
What is null pointer in c?
What is malloc and calloc?
What is a char c?
How does struct work in c?
What is the purpose of sprintf() function?
What are identifiers and keywords in c?
What are the advantages of Macro over function?
What is nested structure with example?
What are pointers? What are different types of pointers?
What are the storage classes in C?
Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)
How can I read in an object file and jump to locations in it?