Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

2. Write a function called hms_to_secs() that takes
three int values&#8212;for hours, minutes, and seconds&#8212;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 / alex chogo

#include<iostream>
using namespace std;

long hms_to_sec(int hr,int mn, int sec);
int main()
{
int hr,mn,sec;
cout<<hms_to_sec(hr,mn,sec);
return 0;
}
long hms_to_sec(int hr,int mn, int sec)
{
cout << "please enter hr, min, and sec" << endl;
cin >> hr>> mn>> sec;
return (hr*60*60)+(mn*60)+ sec;
}

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is a pointer a kind of array?

1180


What is define directive?

1148


What the advantages of using Unions?

1231


write a program for the normal snake games find in most of the mobiles.

2256


Should I learn data structures in c or python?

1024


Why dont c comments nest?

1048


How can I get random integers in a certain range?

1065


What is call by value in c?

1003


a c code by using memory allocation for add ,multiply of sprase matrixes

2797


Explain what math functions are available for integers? For floating point?

1107


Why do we use static in c?

1126


Can a void pointer point to a function?

1020


Who is the founder of c language?

1164


What are the two types of functions in c?

1011


Explain high-order and low-order bytes.

1096