Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Iteration [7/10]

Name of a variable can be composed of any letters, but it cannot contain spaces.
[Run the program]

A println statement scrolls the screen up when the screen is full.

This program prints out the squares of first 50 natural numbers. A square of a number is the number multiplied by itself.

Exercise:

(Challenging exercise!) Change the program so that it outputs results of expression 1000/number.

Remember that arguments of println statement must be separated by commas (,).

Peek at the solution if you can't solve this exercise.

Many differens solutions are possible. Here is one of them:

Solution

    println 1000, "/", number, " = ", 1000/number;

Loading...