Just needed a solution on the exercises below.

**Exercise 2**

A classic problem in introductory programming is the grains of rice on a chess board problem.

Your program should calculate the number of rice grains on the last square of a 64 square chess board given that there is 1 grain of rice on the first square, 2 on the second square, 4 on the third square and so on.

Use a while loop to double the number of rice grains and output the number of grains on the last square. Additionally output the total number of grains.

Check your answer, is it sensible? If not amend your data types.

Exercise 3

Amend program 2 above so that it is a do while loop. Test to make sure that the same number of rice grains is on the last square and that the total is the same.

Exercise 4

The Fibonacci series is another classic computing problem.

The series is formed by adding two numbers in the series to generate the third. Note the first two are 0 and 1, so to make the make number we add 0 + 1 to give 1. The fourth number is obtained by adding the second and third numbers, 1 + 1 gives 2. So the series looks like:

0 1 1 2 3 5 8 13 21

Use a loop to output the first 20 Fibonnaci numbers. Set a counter and output a calculation of number of terms in series.

Exercise 5

Write a program which outputs a series of asterisks (* - stars) to form the following pattern below.

Note this requires you to place one loop inside another loop. An example outline would look like this:

while (test condition1)

{

;

while (test condition2)

{

.;

}

.;

}

The output should look like: (this is a short version, you should have 10 lines of stars)

*

**

***

****

*****

*****

A classic problem in introductory programming is the grains of rice on a chess board problem.

Your program should calculate the number of rice grains on the last square of a 64 square chess board given that there is 1 grain of rice on the first square, 2 on the second square, 4 on the third square and so on.

Use a while loop to double the number of rice grains and output the number of grains on the last square. Additionally output the total number of grains.

Check your answer, is it sensible? If not amend your data types.

Exercise 3

Amend program 2 above so that it is a do while loop. Test to make sure that the same number of rice grains is on the last square and that the total is the same.

Exercise 4

The Fibonacci series is another classic computing problem.

The series is formed by adding two numbers in the series to generate the third. Note the first two are 0 and 1, so to make the make number we add 0 + 1 to give 1. The fourth number is obtained by adding the second and third numbers, 1 + 1 gives 2. So the series looks like:

0 1 1 2 3 5 8 13 21

Use a loop to output the first 20 Fibonnaci numbers. Set a counter and output a calculation of number of terms in series.

Exercise 5

Write a program which outputs a series of asterisks (* - stars) to form the following pattern below.

Note this requires you to place one loop inside another loop. An example outline would look like this:

while (test condition1)

{

;

while (test condition2)

{

.;

}

.;

}

The output should look like: (this is a short version, you should have 10 lines of stars)

*

**

***

****

*****

*****