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
Does * p ++ increment p or what it points to?
What is bash c?
What is the importance of c in your views?
What is structure pointer in c?
Write a program to check whether a number is prime or not using c?
What are the main characteristics of c language describe the structure of ac program?
What is your stream meaning?
A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?
Explain how can type-insensitive macros be created?
How can I use a preprocessorif expression to ?
What is header file in c?
Why do we use main function?
What does the message "automatic aggregate intialization is an ansi feature" mean?
write a program fibonacci series and palindrome program in c
Explain that why C is procedural?