I'm stuck trying to understand what's wrong with my code... When I check it I get this error message: :( input of 1.6 yields output of 7 expected exit code 0, not 1
But getting 7 coins for 1.6$ seems correct to me...Can anybody help? Thanks in advance!
#include <stdio.h>
#include <cs50.h>
#include <math.h>
int main(void)
{
//getting a float type variable from the user and defining integer variables for later use
float change;
int q, d, n, p, cents;
// prompting user to only give me positive values by using a do-while loop
do
{
change = get_float("Change owed: \n");
}
while (change <=0);
//expressing value in cents to avoid problems with decimals
cents = round(change * 100);
//calculating number of coins for each value in order from highest to lowest
q = cents / 25;
cents = cents % 25;
d = cents / 10;
cents = cents % 10;
n = cents / 5;
cents = cents % 5;
p = cents;
//calculating and then printing total number of coins
int c = q + d + n + p;
printf("%i\n", c);
return change;
}