Click 'Run' to go.
A computer programing language can also print the value of a variable. Here we use the term 'variable' to mean the same as one would use the term in Algebra. That is, a variable is a symbol that is a letter of the alphabet, and it holds a value that is a number.
In computer languages you could see a line of code that would look something like this:
x = 5
This is called an assignment statement. The x is the variable that is being assigned a value. It is here assigned the value 5.
An assignment statement at EZ Programing Demos is shown with the let command. So if it were typed out, it would look like this:
If you wanted to print the value of a variable, the name of the variable would be included in the print statement, as in:
Play with the included programing demonstration. Change the number in the let command to understand how you may alter the value assigned to the variable. Change the name of the variable both in the let command and in the print command to understand that you must print the same variable name to which you assigned a value.
Understand that there is a difference between printing a letter of the alphabet and printing the value of a variable. Most computer languages take this into account.
If you want to print a letter of the alphabet, say 'b', then you would use a programing line like this:
Note the quotes in the above line.
However, if you were doing some math with a variable named b, and you wanted to print the number that represented the value of the variable b, then you would use a programing line like this:
Note the lack of quotes in the above line.
The flowchart for this program:
Imaginary language code:
x = 5; print(x);
Suggested next article: