In this program, we will print a table of a number using for loop.
Steps to solve the program
- Take the number 5 as input to print its table.
- Create a variable and assign its value equal to 0.
- Use a for loop to iterate over 1-10.
- Multiply the given number with the loop number and store the result in the created variable.
- Print the result after each iteration.
num = 5
a = 0
for i in range(1,11):
a = i*num
print(i,"*",num,"=",a)
Output :
1 * 5 = 5
2 * 5 = 10
3 * 5 = 15
4 * 5 = 20
5 * 5 = 25
6 * 5 = 30
7 * 5 = 35
8 * 5 = 40
9 * 5 = 45
10 * 5 = 50