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 / htoo cherry

#include <iostream >
Using namespace std ;
long hms_to_secs (int, int, int) ;
int main ()
{int hrs, min, sec;
cout <<"Enter hours" <<endl ;cin>>hrs;
cout <<"Enter minutes " <<endl ;cin>>min;
cout <<"Enter seconds" <<endl ;cin <<sec;
cout <<hrs<<":" <<min<<":" <<sec<<":" <<endl ;
cout <<The time in seconds<<hms_to_secs (int hrs, int min, int sec) ;
}
long hms_to_secs (int h, int m, int s)
return( h*3600+m*60+s);

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the three constants used in c?

772


When is the “void” keyword used in a function?

1199


What is wrong with this initialization?

812


int far *near * p; means

3345


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

2998


Explain can the sizeof operator be used to tell the size of an array passed to a function?

839


What is New modifiers?

909


Why is extern used in c?

867


Explain what is the heap?

837


How we can insert comments in a c program?

884


What is double pointer in c?

794


the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters

2098


What is a macro?

905


How are Structure passing and returning implemented by the complier?

963


Explain the difference between ++u and u++?

871