Learn to Program with ZedLX

Free Online Programming Course for Beginners

Simple Graphics [6/15]

The program starts with a multiline comment, which begins with /* and ends with */. The computer ignores the contents of multiline comments.

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

Exercises:

1. Change the first argument (300) in the disc statement. Try several values between 0 and 700.

2. Swap over the first and the second argument in the disc statement. What effect will this have?

Solution

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

3. Rename the variable y to x in both places. What difference will that make? Verify your answer by clicking on the box below.

Answer

It will make no difference. The computer completely ignores the choice of names given to variables, so any name can be used.

After solving an exercise, it is recommended that you always examine the provided solution.

Loading...