So I'm in pset1 and I'm trying to finish the problem set "change". I have the whole program finished... the problem is that getint() wont let me grab decimal numbers. Im not sure if I have to add a particular codeing or what not, but I know one of you guys do.

So this is just the inital codeing you need to see:

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

int main (void)
    printf ("what would you like change for today sir?\n");
float amount=0;

    while  (amount<=0);

When im putting in my input into the terminal this is what i get:

~/workspace/pset1 $ ./change
what would you like change for today sir?
Retry: .50
Retry: 1.50
Retry: 4
Out of the amount you gave us you will have 16 coins!

1 Answer 1


I hate to state the obvious, but GetInt() will only "Get" an "Int". It won't take a decimal number, only an integer. If only there was a function that would "Get" a "Float"! ;-)

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

  • Thank You! I remember hearing that in the coarse instruction, but obviously i forgot it... Nov 14, 2016 at 19:22

You must log in to answer this question.

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