I need a while loop to only take in positive number. I wrote a while loop but it won't execute and Im not sure what's wrong. My code works fine with a for while loop but when I enter a negative number and run the code it prints out the input, then reprompts the user. I just want it to re-prompt, not print the input too.
Thank you if anyone can help.
This will print the input, then reprompt the user
#include <cs50.h>
#include <stdio.h>
int main(void)
{
float change;
do
{
change = get_float("Change: ");
printf("%f\n", change);
}
while (change < 1);
}
This will not execute at all
#include <cs50.h>
#include <stdio.h>
int main(void)
{
float change;
while (change < 1)
{
change = get_float("Change: ");
printf("%f\n", change);
}
}