1. Write a program to compute the sum of the digits of a given integer number.
2. The numbers in the sequence
1 1 2 3 5 8 13 21 .......
are called Fibonacci numbers. Write a program using a do....while loop to calculate and print the first m Fibonacci numbers.
(Hint: After the fi rst two numbers in the series, each number is the sum of the two
preceding numbers.)
3. Rewrite the program of the Example 8.1 using the for statement.
4. Write a program to evaluate the following investment equation
V = P(1+r)n
and print the tables which would give the value of V for various combination of the
following values of P, r, and n.
P : 1000, 2000, 3000,........, 10,000
r : 0.10, 0.11, 0.12, ......., 0.20
n : 1, 2, 3, ...., 10
(Hint: P is the principal amount and V is the value of money at the end of n years. This
equation can be recursively written as
V = P(1+r)
P = V
That is, the value of money at the end of first year becomes the principal amount for the
next year and so on.)