Print a table of a number using for loop

In this program, we will print a table of a number using for loop.

Steps to solve the program
  1. Take the number 5 as input to print its table.
  2. Create a variable and assign its value equal to 0.
  3. Use a for loop to iterate over 1-10.
  4. Multiply the given number with the loop number and store the result in the created variable.
  5. 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
				
			

print the following pattern

first 20 natural numbers using for loop

Leave a Comment