EZ Programing Demos

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

Links to topics:

Current topic:

Getting numbers

Often you will want to pause the program, ask for some information, and receive it. Here we will be asking for and getting a number.

 Slow  Medium  Fast 
Click 'Run' to go.

There are a lot of ways to get a value into a variable. We could just assign a value within the code using a statement like:

    let x = 5

That is called hard coding the assignment. The variable x would be set to 5 every time the program was run.

However, what if you wanted the user of the program to set the value of a variable differently every time the program was run? Then you would use a process like we are looking at here. You would ask, or prompt, the user for the information and then wait for the user to type in the value.

 

The flowchart for this demo:

 

Here's some imaginary computer code for this program:

    
    x = prompt("Enter value:");
    

 

Suggested next article:

At EZ Math Movie

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.