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 is use of #include in c?

840


can anyone suggest some site name..where i can get some good data structure puzzles???

1856


What is f'n in math?

837


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

2906


Explain what is the advantage of a random access file?

915


What are preprocessor directives in c?

853


What is a newline escape sequence?

873


Why is c known as a mother language?

979


Explain how do you print only part of a string?

938


What is a static function in c?

862


What is c value paradox explain?

806


why we wont use '&' sing in aceesing the string using scanf

2090


Can you write the algorithm for Queue?

1769


What is optimization in c?

759


What is type qualifiers?

884