2. Write a function called hms_to_secs() that takes
three int values—for hours, minutes, and seconds—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
what are non standard function in c
ATM machine and railway reservation class/object diagram
What are multibyte characters?
c program to compute AREA under integral
How can I write a function that takes a format string and a variable number of arguments?
How are structure passing and returning implemented?
in linking some of os executables are linking name some of them
Multiply an Integer Number by 2 Without Using Multiplication Operator
What are the advantages and disadvantages of c language?
What are volatile variables in c?
How do you write a program which produces its own source code as output?
How do I swap bytes?
#include show(int t,va_list ptr1) { int a,x,i; a=va_arg(ptr1,int) printf(" %d",a) } display(char) { int x; listptr; va_star(otr,s); n=va_arg(ptr,int); show(x,ptr); } main() { display("hello",4,12,13,14,44); }
Differentiate between the expression “++a” and “a++”?
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none