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

A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

1166


What does return 1 means in c?

1056


What are the __date__ and __time__ preprocessor commands?

1088


How will you divide two numbers in a MACRO?

1115


int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above

1273


Where is volatile variable stored?

1068


What is the difference between array and pointer in c?

1137


What is a function in c?

1549


Tell us bitwise shift operators?

1076


C program execution always begins with a) #include b) comment (/*-------*/) c) main() d) declaration instructions

1040


Is anything faster than c?

995


What is substring in c?

1180


code for find determinent of amatrix

1942


How the c program is executed?

1139


How can I handle floating-point exceptions gracefully?

1155