Assignment 3 - Flow of Control (for - loop)

1.

Write a C++ program to count down from a positive integer n.

Sample Output
n = 5
5
4
3
2
1
0

   
2. Write a C++ program to print out the reciprocal of the integers from 11 to 22. The output should be in the following format:

1/11 = 0.090909
1/12 = 0.083333
.......
   
3. Write a C++ program to input 6 integers and compute the sum of their squares.
   
4. Write a C++ program to return all the odd integers between m and n inclusively. The program should display at most 5 integers on each line of output.
   
5.

Write a C++ program to generate the multiplication table

Sample Output

1 2 3 4 5 6 7 8 9
2 4 6 8 10 12 14 16 18
3 6 9 12 15 18 21 24 27
4 8 12 16 20 24 28 32 36
5 10 15 20 25 30 35 40 45
6 12 18 24 30 36 42 48 54
7 14 21 28 35 42 49 56 63
8 16 24 32 40 48 56 64 72
9 18 27 36 45 54 63 72 81
   
6. Write C++ programs to input a positive integer n, which lies in between 1 and 20, and output the corresponding number patterns as shown below.

Sample Output
n = 6
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
Sample Output
n = 6
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
Sample Output
n = 6
a
a
b
a
b
c
a
b
c
d
a
b
c
d
e
a
b
c
d
e
f
7. (Optional) Write a C++ program to print a tree as shown below.
 
n=5
     *
    ***
     *
    ***
   *****
     *
    ***
   *****
  *******
     *
    ***
   *****
  *******
 *********
     *
    ***
   *****
  *******
 *********
***********