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
Is array name a pointer?
any "C" function by default returns an a) int value b) float value c) char value d) a & b
What are the advantages of c preprocessor?
What is call by value in c?
Is it possible to execute code even after the program exits the main() function?
Can i use “int” data type to store the value 32768? Why?
What does the function toupper() do?
Describe the modifier in c?
Why & is used in scanf in c?
What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers
Write a c program to demonstrate character and string constants?
How do you print only part of a string?
When is the “void” keyword used in a function?
how do you programme Carrier Sense Multiple Access
How is a macro different from a function?