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

Differentiate between #include<...> and #include '...'

1016


What is the best organizational structure?

1076


write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?

2087


What is null pointer in c?

960


What is malloc and calloc?

1018


What is a char c?

1003


How does struct work in c?

1040


What is the purpose of sprintf() function?

1072


What are identifiers and keywords in c?

1050


What are the advantages of Macro over function?

1951


What is nested structure with example?

1032


What are pointers? What are different types of pointers?

1081


What are the storage classes in C?

1115


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

1238


How can I read in an object file and jump to locations in it?

999