September 2015
Beginner
238 pages
4h 2m
English
A variable stores a value in memory so that it can be used later in a program. The variable can be used many times within a single program, and the value is easily changed while the program is running.
One of the reasons we use variables is to avoid repeating ourselves in the code. If you are typing the same number more than once, consider using a variable instead so that your code is more general and easier to update.
For instance, when you make the y coordinate and diameter for the three circles in this example into variables, the same values are used for each ellipse:
size(480,120);inty=60;intd=80;ellipse(75,y,d,d);// Leftellipse(175,y,d,d);// Middle ...
Read now
Unlock full access