int flag = 0;
int price = 0;
while (flag==0)
{
printf(\"\\nEnter Product price: \");
scanf(\"%d\",&price);
if (price==0)
printf(\"input not
The "answers" that say it will because there is a '\n' in the buffer are mistaken -- scanf("%d", ...)
skips white space, including newlines.
It goes into an infinite loop if x
contains 0 and scanf
encounters a non-number (not just whitespace) or EOF because x
will stay 0 and there's no way for it to become otherwise. This should be clear from just looking at your code and thinking about what it will do in that case.