Quote:
Originally Posted by kalli002
is that because when we hit "0"and stop the while loop then the compiler takes x value as "0" for the hole program
|
You got the right idea. In most high level languages, the value of a variable remain the same until explicitly changed, drops out of scope (when you're out of main()), or when the program exits. If x was zero the last time while() was executed, it will remain zero for the rest of the runtime (unless you re-initialize it like I did)