0

my code is working and displaying as the example in ~cs50/pset1/greedy but it is still giving me errors. Can someone give me some pointers please?

#include <cs50.h>
#include <stdio.h>
#include <math.h>

int main(void)
{
    int quarter = 25;
    int dime = 10;
    int nickel = 5;
    int penny = 1;
    float dollar;
    int count = 0;

do
{
    printf("O hai! How much change is owed? \n");
    dollar = GetFloat();
}
while(dollar < 0);

//converting dollar amount to cents
dollar= dollar * 100;

int amount = round(dollar);


while(amount >= quarter)
{
    count++;
    amount = amount - quarter;

}

while(amount >= dime)
{
    count++;
    amount = amount - dime;
}

while(amount >= nickel)
{
    count++;
    amount = amount - nickel;
}

while(amount >= penny)
{
    count++;
    amount = amount - penny;
}

printf("%d \n", count);

}

Greedy checks

1 Answer 1

1

try removing the space between %d and \n in your last line. The checks expect a very specific output so won't be expecting a space after the number

2
  • That was the issue. Thanks a lot :D
    – Aeonify
    Oct 27, 2016 at 14:19
  • don't forget to mark as the answer :)
    – Ian Grover
    Oct 27, 2016 at 14:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .