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 a newline escape sequence?

661


how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions

2717


What is the use of ?

615


Tell us the use of fflush() function in c language?

631


Is it cc or c in a letter?

554






What are identifiers c?

560


what are enumerations in C

718


Why shouldn’t I start variable names with underscores?

621


Why string is used in c?

574


What is an auto keyword in c?

636


Do character constants represent numerical values?

833


Do pointers take up memory?

650


find the sum of two matrices and WAP for it.

626


Why & is used in c?

707


please give me some tips for the placement in the TCS.

1627