Menu

Using variables

Gianluigi Forte

Using variables

Variables can be used to store intermediate result of an operation for later reuse.
Let make an example: we want to compute the area of two squares. The first has a side of 3.14 and the second has a side that is double of the other. So let start to store the side of the first in the variable L1.

L1=3.14
ans=3.14

Then we can use L1 to compute the second square side L2

L2=L1*2
ans=6.28

and the area of first square A1.

A1=L1*L1
ans=9.8596

To compute the area of second square A2 is possible to use the variable L2

A2=L2*L2
ans=39.4384

At this point we can show the status of all the variable using the command ls.

ls
[Variable: Name={ans}, Value={39.4384}]
[Variable: Name={L1}, Value={3.14}]
[Variable: Name={L2}, Value={6.28}]
[Variable: Name={A1}, Value={9.8596}]
[Variable: Name={A2}, Value={39.4384}]

or in a graphical way view->variables or the accelerator Ctrl+Shift+V

Note: it is possible to use ans, that contains the last result of operation, like any other variable.


Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.