0

Can you please look at my code and tell me if I am close or where to go to get help. I get an error at the G in this line.
change= get_positive_float("Change owed: \n");

include

include

include

int main (void) { int i = 0; float change = 0; int counter = 0; int qr =25; int dm = 10; int nk = 5; int pn = 1; i = i *100;

// ask user for amount owed
 do 
 {
     change= get_positive_float("Change owed: \n");
       printf("coin: \n");
 }

// check against 25
while
    (i >= qr)
    ;
    {
        i++;
        i-= 25;
    }

// check against 10
while
    (i >= dm)
    ;
     {
        i++;
        i -= 10;
    }

// check against 5
while
    (i >= nk)
    ;
     {
        i++;
        i -= 5;
    }
// check against 1
while
    (i >= pn)
    ;
     {
        i++;
        i-= 1;
    }
    printf("int: %i =\n", i);

}

0

In the CS50 lab, to the left side of the sandbox, there's documentation, a text walk through and a video walk through. Read through, and watch the video to get a better understanding of the problem. It's easier to separate the problem into chunks (such as accepting the correct user input) and test to see that each chunk works, so that once it does the thing you want it to, you can almost forget about it. Using Printf to let you know what the values are at each stage helps. In the CS50 lab sandbox you can make a new file tab so that you can test stuff out on its own before putting it all together. Also, creating a .txt file and writing a pseudocode approach for how you're planning on solving each bit helps lots.

It's probably better if nobody tell you exactly how to solve the problem, because if you have to figure it out on your own, you will learn and remember it better because you really have to understand the problem. Good luck, you'll get it.

You must log in to answer this question.

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