A variable is a piece of information that the program needs, but may change.
For example, let’s take a calculator program, you type 2 + 2 and get “4.” The 4 is stored as a variable so it knows what to display. From here you can type “x 3,” but until you hit “=” all it knows so far is you want to multiply by 3, so it stores that as another variable. Hit “=” and now the number on screen says 12, you changed that variable that said 4 before to now say 12.
Or we could look at a more obvious use of changing data by looking at games. The way you’re facing, your health and ammo, everything that is able to change is probably stored as a variable.
Latest Answers