Practice Exercises
Practice your problem solving skills in these challenge exercises.
We'll cover the following
In this lesson, practice what we have learned so far by solving some challenges.
Printing odd multiples
Modify the program below so that only the odd multiples (1, 3, 5, 7 and so on) of the number are printed up to its 15th multiple.
So, for example, for the number 6, the odd multiples up to its 10th multiple would be:
6 x 1 = 6
6 x 3 = 18
6 x 5 = 30
6 x 7 = 35
6 x 9 = 54
Good luck!
//This program should print the table up to 15th multiple{int table = 6;// write code herereturn 0;}
If you have solved the problem, congratulations! 🎉
Printing even multiples
Modify the program below so that only the even multiples (2, 4, 6, 8, and so on) of the number are printed up to the 16th multiple.
So, for example, for the number 6, the even multiples up to its 10th multiple would be:
6 x 2 = 12
6 x 4 = 24
6 x 6 = 36
6 x 8 = 48
6 x 10 = 60
Good luck! 👍
//This program should print the table up to 16th multiple{int table = 6;// write your code herereturn 0;}
If you have solved the problem, congratulations!