Variables
We use variables to store data.
A variable has a name and a type.
Let's say we are calculating the total amount that we spent on some items.
We can use 3 variables:
amount
of typeInteger
price
of typeReal
total
of typeReal
Before we use a variable, we must declare it.
Click the line and select the item.
Then:
- enter
amount
for variable name - select
Integer
for its type - enter
3
for its initial value
Do the same for price
, set its type to Real
and value to 1.5
Now we can finally calculate the total amount.
Declare total
, set its type to Real
and value to amount * price
This last part is very important, you can use variable name as a value!
Lastly, add total block to print the value of total
.