EZ Programing Demos

Slow motion, step by step, animated demonstrations of basic computer programing techniques

Links to topics:

Current topic:

Printing letters and variable values

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:

    print "b"

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:

    print b

Note the lack of quotes in the above line.

 Slow  Medium  Fast 
Click 'Run' to go.

Here we see the difference between printing a string literal and printing the value of a variable. The string literal can look a lot like a variable name. However, the string literal will be within quotes and the variable name will not.

Although our variables at EZ Programing Demos are all single letter variables, like variables are usually written in mathematics, often computer languages feature long variable names. So, you could use a variable named bankBalance to hold the amount of money in a bank account rather than use a variable named simply b.

Using long variable names makes it important to understand the difference between printing string literals and printing the value of a variable, since long variable names can look a lot like string literals. String literals, of course, have quotes.

 

This is the flowchart for this program demo:

 

Here's how this demo could look in imaginary computer code:

    
    printLine("a");
    
    a = 5;
    
    printLine(a);
    

 

Suggested next article:

EZ Math Movie is a site that can help you experiment with and understand many topics in mathematics. Its main feature is an interactive animated (x, y) graph that you control with an actual programing language. There are many examples and tutorials, and EZ Math Movie is crossed referenced with both EZ Programing Demos and Zona Land Education.

 

Zona Land Education is a site with explanations and interactive diagrams covering many topics in physics and mathematics. Zona Land Education is cross referenced with EZ Math Movie, and it contains several animations that use EZ Math Movie's programing language.