Not quite sure what the problem is here, but I think it has something to do with my loops. I've been setting up the code a little at a time, adding the sections for each type of coin one at a time. This setup worked fine with just the "quarters" loop, but when I added "dimes", it started giving me strange outputs. For example: if I input ".25", the program outputs "1123926981" as the number of coins needed to make the change. Any ideas on why this is happening and how to debug would be much appreciated.
#include <stdio.h>
#include <math.h>
#include <cs50.h>
int main(void)
{
float (n);
do
{
printf("Change Owed:");
n = GetFloat();
}
while (n < 0);
n = round(100 * n); int(owed) = n;
int(coins);
int(quarters);
int(dimes);
while(owed >= 25)
{
quarters = owed/25;
owed = owed % 25;
}
while(owed >= 10)
{
dimes = owed/10;
owed = owed % 10;
}
coins = quarters + dimes;
printf("%d\n",coins);
}