I've trashed this code and started from scratch about twenty times. Starting with step 1, getting a user's input, and I'm having problems even with that.

I've tried declaring change_i and change_f outside of the do-while loop, included and omitted the "= 0", I've omitted the "do", put the "while" inside of the {} of the "do", still missing something.

At one point, I was able to prompt the user for an input, but all it does is keep asking for inputs for eternity, no matter the input.

Can someone help me identify why I am getting so many errors with this code?


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

int main(void)
int change_i = 0;
printf("Change due: \n");
float change_f = GetFloat();
int change_i = (100 * change_f);
while (change_i < 0);

When your change_i is multiplied, it will always be greater than 0, so the loop won't work! Try to create a loop so that the loop executes once if it is successful with change_i. Also you need to declare float change_f before the do-while loop.

You must log in to answer this question.

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