0

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;

    do
    {
   amount=GetInt();
    }
    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?
.25
Retry: .50
Retry: 1.50
Retry: 4
Out of the amount you gave us you will have 16 coins!
0

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. ;-)

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

You must log in to answer this question.

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