I'm trying to create a solution for pset1 cash.c, the code below is not meant to be the final implantation, just a cursor to figure out the problem. When I run this code it works for values .01 to .05 but when I input anything higher that requires pennys the program fails to count the pennies. You can run this only in the cs50 IDE. Please help.
#include <stdio.h> #include <cs50.h>
int main(void) { float q = 0.25; float d = 0.1; float n = 0.05; float p = 0.01; int qu = 0; int du = 0; int nu = 0; int pu = 0;
#include <stdio.h>
#include <cs50.h>
int main(void)
{
float q = 0.25;
float d = 0.1;
float n = 0.05;
float p = 0.01;
int qu = 0;
int du = 0;
int nu = 0;
int pu = 0;
float f = get_float("Change owed: ");
while (f >= q)
{
f = f - q;
qu++;
}
while (f >= d)
{
f = f - d;
du++;
}
while (f >= n)
{
f = f - n;
nu++;
}
while (f >= p)
{
f = f - p;
pu++;
}
printf("quarters: %i, dimes: %i, nickles: %i, pennys: %i\n", qu, du, nu, pu);
}
}