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


Please Help Members By Posting Answers For Below Questions

What is extern c used for?

563


What are qualifiers?

611


5 Write an Algorithm to find the maximum and minimum items in a set of ‘n’ element.

1576


Can a program have two main functions?

565


What is the use of static variable in c?

589






The statement, int(*x[]) () what does in indicate?

640


What are the different types of control structures in programming?

654


What does int main () mean?

541


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

2787


What is the advantage of c?

607


What is a spanning Tree?

946


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?

571


‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .

2366


Give me the code of in-order recursive and non-recursive.

878


Can you add pointers together? Why would you?

636