This is part of code from my greedy.c
The purpose of this do while loop is to get a valid input.
I'm having trouble, I tested it outside do while loop and it was working fine.
I think that mistake is really dumb but I really need help!!
I'm stuck here... :-(
void calc(int number, int change, int coins)
{
int result = change / number;
coins = coins + result;
change = change % number;
}
int main(void)
{
int change;
do
{
printf("How much I owe you: ");
change = round(GetFloat() * 100);
}
while (change < 0);
int coins = 0;
while (change > 0)
{
if (change >= 25)
{
calc(25, change, coins);
}
if (change >= 10)
{
calc(10, change, coins);
}
if (change >= 5)
{
calc(5, change, coins);
}
if (change >= 1)
{
calc(1, change, coins);
}
}
printf("Minimum number of coins needed is: %i \n", coins);
return 0;
}