## Count and Sum [1/8]

### Count and Sum

The fourth statement of this program increases the value of variable b by 6.

Here are four different ways to increase the value of a variable by 1.

There are other ways to modify the value of a variable.

The text after the symbols '<<' is called a **comment**.
Comments are ignored by the computer.

This program prints out the first 10 odd numbers.

This program calculates the sum of the first 10 natural numbers.

What is the sum of the first 100 natural numbers?

This program calculates the sum of squares of the first 9 natural numbers.

This program calculates the sum of 9 random numbers.

Important:

a variable introduced inside a statement block gets removed
when the statement block has completed execution.

In this example, the variable x,
which is introduced inside a statement block,
is not available outside the statement block.
The loop control variable i
is also not available outside the loop.

This program rolls the dice 15 times and counts how many times it got a 6.

### Exercise:

Modify the program so that it rolls two dice 15 times. It should count how many times it got doubles.

Solution

... #num dice1 = rn(6); #num dice2 = rn(6); println "Dice roll: ", dice1," ",dice2; if dice1=dice2 ...