this is my first time using functions and i would like to know how i should pass the seconds and minutes from the readtime function to the displaytime function?
Code:
#include <iostream.h>
//------------------------------------------------------------------------------------------------
int ReadTime(int Minutes, int Seconds) // dont see the purpose of this but the book im using says to have 2 parameter :|
/* get seconds and time */
{
cout<<"\tEnter minutes: ";
cin>>Minutes;
cout<<"\tEnter seconds: ";
cin>>Seconds;
return (Minutes, Seconds);
}
//------------------------------------------------------------------------------------------------
void DisplayTime(int Minutes, int Seconds)
/* display the time in hh:mm:ss form */
{
int Hours=0;
while(Minutes>60)
{
if (Minutes>=60)
{
Minutes=Minutes-60;
Hours++;
}
if (Seconds>=60)
{
Seconds=Seconds-60;
Minutes++;
}
}
cout<<Hours<<":";
if(Minutes<10)
{
cout<<"0"<<Minutes<<":";
}
else if(Minutes>=10)
{
cout<<Minutes<<":";
}
if(Seconds<10)
{
cout<<"0"<<Seconds;
}
else if(Seconds>=10)
{
cout<<Seconds;
}
cout<<endl;
}
//------------------------------------------------------------------------------------------------
int main()
{
int Minutes=1,Seconds=1;
cout<<"Enter a time:"<<endl;
ReadTime(Minutes, Seconds);
cout<<"Your time was ";
DisplayTime(Minutes, Seconds);
return (0);
}