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

What is call by reference in functions?

1320


Which is better pointer or array?

973


Why is it usually a bad idea to use gets()? Suggest a workaround.

1689


a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none

1202


how to introdu5ce my self in serco

1938


What is a constant?

995


what are non standard function in c

1849


Take an MxN matrice from user and then sum upper diagonal in a variable and lower diagonal in a separate variables. Print the result

1846


Explain #pragma statements.

978


What are different storage class specifiers in c?

1042


Explain how can you restore a redirected standard stream?

1029


while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

1197


Is the exit() function same as the return statement? Explain.

1035


What is scope rule of function in c?

1029


writ a program to compare using strcmp VIVA and viva with its output.

1975