Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Simple Graphics [6/15]

The given program begins with a multiline comment. A multiline comment begins with the symbols /* and it is ended by symbols */. The contents of multiline comments are ignored by the computer.

To draw a vertical line of discs, the second coordinate (commonly named y ) of the disc statement is changing.

Exercises:

1. What happens when you change the first argument (i.e. the value 300) in the disc statement? Try several values in the range from 0 to 700.

2. Switch over the first and the second argument of the disc statement. Can you guess what difference will that make?

Solution

    disc(y, 300, 20, /red);

3. If you change the name of the variable y to x, in both places, what difference would that make? Verify your answer by clicking on the box below.

Answer

That would make no difference. The computer completely ignores names of variables, so you can name the variables however you like.

After you have solved an exercise, it is recommended to always examine the provided solution.

Loading...