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 extern c used for?
What are qualifiers?
5 Write an Algorithm to find the maximum and minimum items in a set of ‘n’ element.
Can a program have two main functions?
What is the use of static variable in c?
The statement, int(*x[]) () what does in indicate?
What are the different types of control structures in programming?
What does int main () mean?
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
What is the advantage of c?
What is a spanning Tree?
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .
Give me the code of in-order recursive and non-recursive.
Can you add pointers together? Why would you?