Basic distance conversion program This is a simple program to convert miles, yards, feet, and inches appropriately. Everything intended for works but I feel my program is very redundant. How can I make it more efficient and less lines of code? I tried % but failed to find way to increment next values.

#include &lt;iostream&gt;
using namespace std;

//NO GLOBAL VARIABLES

int main()
{
    int m, y, f, i;
    int a, b, c;
    cout &lt;&lt; "Enter: ";
    cin &gt;&gt; m &gt;&gt; y &gt;&gt; f &gt;&gt; i;
    cout &lt;&lt; "You enter: " &lt;&lt; m &lt;&lt; "miles " &lt;&lt; y &lt;&lt; "yards "&lt;&lt; f &lt;&lt; "feet " &lt;&lt; i    &lt;&lt; "inches " &lt;&lt; endl;
    cout &lt;&lt; "Convert the distance" &lt;&lt; endl;

    // 2miles 1761yards 4feet 27inches
    // = 3miles 2yards 3feet 3inches

    //ensure mile is zero or positive
    if(m&lt;0)
    {
        return 0;
    }

    //yard to mile conversion
    for(a=0; a&lt;100; a++)
    {
        if(y&lt;0)
        {
             return 0;
        }
        if(y&gt;1760)
        {
            m++;
            y -= 1760;
        }
        if(y==1760)
        {
            y = 0;
            m++;
        }
        if(y&lt;1760)
        {
            y = y;
        }
    }

    //feet to yard conversion
    for(b=0; b&lt;100; b++)
    {
        if(f&gt;3)
        {
            y++;
            f -= 3;
        }
        if(f==3)
        {
            y++;
            f= 0;
        }
        if(f&lt;3)
        {
            f = f;
        }
        if(f&lt;0)
        {
            return 0;
        }
    }

    //inches to feet conversion
    for(c=0; c&lt;100; c++)
    {
        if(i&gt;12)
        {
            f++;
            i -=  12;
        }
        if(i==12)
        {
            f++;
            i = 0;
        }
        if(i&lt;0)
        {
            return 0;
        }
    }

    cout &lt;&lt; "After conversion: " &lt;&lt; m &lt;&lt; "miles " &lt;&lt; y &lt;&lt; "yards "&lt;&lt; f &lt;&lt; "feet  "   &lt;&lt; i &lt;&lt; "inches" &lt;&lt; endl;
    return 0;
}
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