It's me agian, with another noob problem..=( but I just can't seem to figure it out.
This time I am writing code for a program that is suppose to have 2 functions.
1)is to intake the time in minutes and seconds from the operator called ReadTime()
2)is to rewrite the time in the format of hour:min:second called DisplayTime()
however my time displayed by DisplayTime() will be 124421323:1213245:1, or something ridiculous
#include <iostream>
usingnamespace std;
void input(int& i, int& k) { /*pass it by reference then you can use two values at one go*/
cout<<"Enter minutes:";
cin>>i;
cout<<endl<<"Enter seconds:";
cin>>k;
cout<<endl;
}
int Display() {
int min, sec,hour;
input(min, sec);
hour= (min/60);
min=(min % 60) + (sec / 60);
cout<<"your time was "<<":"<<hour<<"hrs :"<<min<<"mins : & "<<sec<<"secs"<<endl;
return 0;
}
int main()
{
Display();
system("pause");
return 0;
}
Sorry i did not create a better maths algo for the calculations... you do the rest... ('',).
but for "magnificence's" reply, if you have three reference parameters in the function, does that mean when calling the function in int main you have to attribute an value to "int &hour?" or can you just leave it blank?''
UPDATE: o nvm, it can just return the results for the display()