The goal of this function is to convert a large number of inches into the format 'miles, yards, feet, and inches'.
But for some reason my code is stuck in an infinite loop in this function. I cannot figure out how to rewrite it so it is not stuck in the loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void Convert(int i, Distance& d)
{
d.feet = d.feet + 1; //each time you take away 12, add another to the inches
}
while ( d.feet > MAX_FT)
{
d.yards = d.yards + 1; //took away 3 ft to add to the yardcount
}
while (d.yards > MAX_YRDS)
{
d.miles = d.miles + 1;
}
}