Answer the question
In order to leave comments, you need to log in
Why does the loop run indefinitely when a non-numeric value is entered?
#include <stdio.h>
int main()
{
float firstNum;
while (scanf("%f", &firstNum) == 0) {
printf("Enter a NUMBER: ");
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
What is the problem?
scanf("%*[^\n]");
:while (scanf("%f", &firstNum) == 0) {
printf("Enter a NUMBER: ");
scanf("%*[^\n]");
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question