Return the amount of Quarters, Dimes, Nickels, and Pennies that you would get from the total amount of change I made windows form in C# that takes the amount of change given, 1-99 and tells you the amount of quarters, dimes, nickels, and pennies you would get back. Can I improve the math in any way? It takes the total change and subtracts the value of the largest coin value that applies till the change becomes equal to zero.

        //set the variables
        int quarters = 0;
        int dimes = 0;
        int nickels = 0;
        int pennies = 0;
        int change = Convert.ToInt32(txtChange.Text);

        //logic
        do
        {
            if (change &gt;= 25 &amp;&amp; change &lt;= 99)
            {
                change = change - 25;
                quarters++;
            }
            else if (change &lt;= 24 &amp;&amp; change &gt; 9)
            {
                change = change - 10;
                dimes++;
            }
            else if (change == 5)
            {
                change = change - 5;
                nickels++;
            }
            else if (change &lt;=4)
            {
                change = change - 1;
                pennies++;
            }

            txtQuarters.Text = quarters.ToString("n");
            txtDimes.Text = dimes.ToString("n");
            txtNickels.Text = nickels.ToString("n");
            txtPennies.Text = pennies.ToString("n");

        } while (change &gt; 0);
Your loop only adds one coin to the change every repetition, which can be done faster: you don;t need the else if.

You don't want to set your Text properties inside your loop, but only when you're finished.

Also, you want to check if change > 99 before starting, otherwise your loop never ends.

Instead of 

something = something + x;


you can use 

something += x;


Once you're down to pennies, the number of pennies is your remaining change.

Instead of adding one coin every time, simply add all the quarters possible, then all the dimes, etcetera:

if (change &gt; 99) throw new ArgumentOutOfRangeException("Too much change!");

while (change &gt; 24)
{
    change -= 25;
    quarters++;
}
while (change &gt; 9)
{
    change -= 10;
    dimes++;
}
while (change &gt; 4)
{
    change -= 5;
    nickels++;
}

pennies = change;


Now, you can actually do away with all the loops very simply, by dividing the remaining change by the size of your next coin. The resulting integer is the amount of coins. 

Then you get:

int quarters = change/25;
change -= quarters*25;
int dimes = change/10;
change -= dimes*10;
int nickels = change/5;
int pennies = change - nickels * 5;


Even shorter, using the % (modulo) operator:

int quarters = change/25;
change %= 25;
int dimes = change/10;
change %= 10;
int nickels = change/5;
int pennies = change%5;