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 / muhammad ali
#include<iostream>
using namespace std;
int hms_to_sec(int hr,int min, int sec);
int main()
{
int hr,min,sec;
int result =hms_to_sec(hr,min,sec);
cout << "result = " << result;
system("pause");
return 0;
}
int hms_to_sec(int hr,int min, int sec)
{
int seconds =0;
cout << "please enter hr" << endl;
cin >> hr;
cout << "please enter min" << endl;
cin >> min;
cout << "please enter sec" << endl;
cin >> sec;
seconds = (hr*60*60)+(min*60)+sec;
return seconds;
}
| Is This Answer Correct ? | 65 Yes | 13 No |
Post New Answer View All Answers
Explain how do you determine a file’s attributes?
Explain logical errors? Compare with syntax errors.
Why double pointer is used in c?
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
Can a file other than a .h file be included with #include?
What is c language & why it is used?
write a program to find out prime number using sieve case?
Differentiate between functions getch() and getche().
Why calloc is better than malloc?
What does char * * argv mean in c?
define string ?
Differentiate between a structure and a union.
What is a pointer and how it is initialized?
Explain the use of #pragma exit?
How to explain the final year project as a fresher please answer with sample project