int elapsedtime(int time1, int time2)
{
int minutes1 = ((time1/100*60)+(time1%100);
int minutes2 = ((time2/100*60)+(time2%100);
return(minutes2-minutes1);
}
/**************************************************************************************
do
{
cout << "What is your starting time? ";
cin >> time1;
cout << "What is your ending time? ";
cin >> time2;
if (time2>=time1)
{
cout << "Your elapsed time is " << elapsedtime <<endl;
cout << "If you would like to enter other times?(Y/N)" <<endl;
cin >> choice;
}
else
{
cout << "Error: Your starting time must be lower than your ending time."<<endl;
cout << "If you would like to enter other times?(Y/N)" <<endl;
cin >> choice;
}
}
I keep getting an output of 1 for every elapsed time?
You have
Did you mean
Update
For some reason,
does not produce a compiler error under g++ 4.7.3 even though the intent is to use
elapsedtime(time1, time2)
.I was able to successfully compile and build:
Perhaps another SO post is needed to answer the question, "How does g++ not report error with the above code?".