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 / muhammad ali

#include<iostream>
using namespace std;
int hms_to_sec(int hr,int min, int sec);
int main()
{
int hr,min,sec;


int result =hms_to_sec(hr,min,sec);
cout << "result = " << result;
system("pause");
return 0;
}

int hms_to_sec(int hr,int min, int sec)
{
int seconds =0;
cout << "please enter hr" << endl;
cin >> hr;
cout << "please enter min" << endl;
cin >> min;
cout << "please enter sec" << endl;
cin >> sec;

seconds = (hr*60*60)+(min*60)+sec;
return seconds;

}

Is This Answer Correct ?    65 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how do you determine a file’s attributes?

1009


Explain logical errors? Compare with syntax errors.

1026


Why double pointer is used in c?

998


An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

1119


Can a file other than a .h file be included with #include?

1111


What is c language & why it is used?

1047


write a program to find out prime number using sieve case?

2046


Differentiate between functions getch() and getche().

1000


Why calloc is better than malloc?

983


What does char * * argv mean in c?

1010


define string ?

1061


Differentiate between a structure and a union.

1237


What is a pointer and how it is initialized?

1094


Explain the use of #pragma exit?

1134


How to explain the final year project as a fresher please answer with sample project

918