Basic distance conversion program
As you guessed, you can make your code much more performant/robust by using % instead of for loops to convert the distances.

An example with just yards you would do something like:

m = 0;
y = 1761;
m += (y / 1760); // add the number of whole miles
y = (y % 1760);  // set to the number of remaining yards


At the end of that you'll see that:

m == 1
y == 1