What is a variable in programming?

1.56K views

What is a variable in programming?

In: Other

11 Answers

Anonymous 0 Comments

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.

You are viewing 1 out of 11 answers, click here to view all answers.