scanf inside while loop

what does this statement means–

what if i write 0 ar any other value instead of 1,

this means th loop will execute till the input is 1

scanf() function returns number of items it successfully reads. Since in your case it is reading one number n, scanf() returns 1. When you give a input file for the code to run, it returns 0 on reaching end of the file (EOF).

1 Like

That’s wrong. It need not be that input is 1 always. It keeps on executing the loop successfully for whatever number scanf() reads.

Scanf returns number of inputs taken, not the input value itself