Thread: hay
View Single Post
Old Mar 3rd, 2008, 8:10 AM   #4
OpenLoop
Expert Programmer
 
OpenLoop's Avatar
 
Join Date: May 2005
Location: East Lansing, MI
Posts: 663
Rep Power: 4 OpenLoop is on a distinguished road
Re: hay

Quote:
Originally Posted by kalli002 View Post
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)
OpenLoop is offline   Reply With Quote