Learn to Program with ZedLX

Free Online Programming Course for Beginners

Basics of for Loops [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 calculates and prints the squares of the first 50 natural numbers. The square of a number is the result of multiplying the number by itself.

Exercise:

Modify the program so that it outputs the results of the expression 1000/number.

Remember to keep the arguments in the println statement separated by commas (,).

If you're stuck, you can peek at the solution.

Many different solutions are possible. Here's one example:

Solution

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

Loading...