-
showTime()?
Code:
#include<iostream>
#include<conio.h>
using std::cout;
using std::cin;
using std::endl;
// function prototype
void showTimeH( int );
void showTimeM( int );
int main()
{
// declare variable
int hours, minutes, seconds;
// read time in format h/m/s
cout<< "What is the time now:(h/m/s)";
cin>> hours >> minutes >> seconds;
// show time in seconds
// call functions showTimeH() % showTimeM()
cout<< "Hours " << "Minutes " << "Seconds" <<endl;
cout<< showTimeH( hours ) << "-" << showTimeM( minutes ) << "-"<< seconds;
getch();
}
// function definition
void showTimeH( int hValue )
{
cout<< hValue*60;
}
void showTimeM( int mValue )
{
cout<< mValue*60;
}
The functions showTimeH( hours )
&
showTimeM( minutes )
donot work? They should give hours*60 = ........ seconds and minutes*60=........seconds?
respectively
?:confused:
-
because showTimeH and showTimeM aren't supposed to output anything, they should return a value, something like this:
Code:
int showTimeH(int hValue) {
return 60 * hValue;
}
int main(void) {
int hours;
cin >> hours;
cout << showTimeH(hours);
}
Another note, I guess that multiplying hValue by 60 gives the number of minutes, and I guess this isn't what you want it to do, so could you please explain more what are you actually trying to do?
-
Yes it works and sorry i missed another *60 in hours to convert it into secds/ thanku