Es un programa que te dice el valor de las vueltas en billetes y monedas. Pero es demasiado lento con valores mas complejos. Esta es una parte de la definicion de la funcion que hace el cambio, el resto es todo igual bajando el tamaño del billete o la moneda hasta llegar a 1 centimo.
#include <stdio.h>
float cambio(float total, float importe)
{
float x=0;
int fivehun = 0, twohun = 0, onehun = 0, fifty = 0, twenty = 0, ten = 0, five = 0, two = 0, one = 0, ofifty = 0, otwenty = 0, oten = 0, ofive = 0, otwo = 0, oone = 0;
if (total <= importe)
{
x = importe - total;
if (x >= 500) //500
{
for (int i = 500; i <= x; i += 500)
{
fivehun++;
}
}
x = x - fivehun * 500;
if (x >= 200) //200
{
for (int i = 200; i <= x; i += 200)
{
twohun++;
}
}
x = x - twohun * 200;
}
else
return 0;
}