# pset1 greedy.c problem

I've coded this problem set and it works completely fine on my machine printing all desired output.

0.41 output: 4 and so on.

However, in gradebook it says it did not get the required output for given inputs. why so? I'm on windows machine.

``````/**
*
* greedy.c
*
* Ashish Patel
* ashish.xxxxxxxxxxxxxx@gmail.com
*
* CS50 problem set 1
* greedy algorithms finds minimum number of coins to make change
*
*/

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

int main(void)
{
float n;
int count = 0, amount;

// prompts user for amount owed and validates input
do
{
printf("How much change is owed?\n");
n = GetFloat();
}
while (n < 0);

// convert input into cents
n *= 100.0;
amount = (int) round(n);

// while quarter can be used
while (amount >= 25)
{
count++;
amount -= 25;
}

// while dimes can be used
while (amount >= 10)
{
count++;
amount -= 10;
}

// while nickels can be used
while (amount >= 5)
{
count++;
amount -= 5;
}

// while pennies can be used
while (amount >= 1)
{
count++;
amount -= 1;
}

// prints the minimum number of coins for change
printf("%d", count);

return 0;
}
``````
• hi! May I ask why did you put 'int count = 0, amount;' together? Dec 8 '17 at 21:25

Add a new line at the end of your `printf` string like that:
``````printf("%d\n", count);
• `n` is a float. By calling `round()` on that float we "round" it to its closest integer (for example 3.4 becomes 3.0 and 3.5 becomes 4). But the return value of `round()` is still a float, so we cast it to an int using `(int)` in front of the call to `round()`. We then assign the integer result to the variable `amount`. Dec 15 '16 at 21:18