1. Write an object-oriented program in C++ using polymorphic technique that prints either the number and its square or the number and its cube from 0 to 100.
2. Modify the above program so that it prints the number, square and cubes of only even numbers from 0 to 100 with the same output.
3. Write a program in C++ to generate the following series of numbers using polymorphism.
(i) | (ii) |
1 | 1 |
2 1 | 1 2 |
3 2 1 | 1 2 3 |
4 3 2 1 | 1 2 3 4 |
5 4 3 2 1 | 1 2 3 4 5 |
6 5 4 3 2 1 | 1 2 3 4 5 6 |
7 6 5 4 3 2 1 | 1 2 3 4 5 6 7 |
8 7 6 5 4 3 2 1 | 1 2 3 4 5 6 7 8 |
9 8 7 6 5 4 3 2 1 | 1 2 3 4 5 6 7 8 9 |
(iii) | (iv) |
9 8 7 6 5 4 3 2 1 | 1 2 3 4 5 6 7 8 9 |
8 7 6 5 4 3 2 1 | 1 2 3 4 5 6 7 8 |
7 6 5 4 3 2 1 | 1 2 3 4 5 6 7 |
6 5 4 3 2 1 | 1 2 3 4 5 6 |
5 4 3 2 1 | 1 2 3 4 5 |
4 3 2 1 | 1 2 3 4 |
3 2 1 | 1 2 3 |
2 1 | 1 2 |
1 | 1 |