Javatpoint Logo
Javatpoint Logo

Write a program to print the following pattern.

1

2   4

3  6   9

4  8 12 16

5 10 15 20 25

6 12 18 24 30 36

7 14 21 28 35 42 49

8 16 24 32 40 48 56 64

9 18 27 36 45 54 63 72 81

10 20 30 40 50 60 70 80 90 100

Algorithm

  • STEP 1: START
  • STEP 2: SET lines =10
  • STEP 3: SET i=1
  • STEP 4: REPEAT STEP 5 to 9 UNTIL i is less than or equals to lines
  • STEP 5: SET j=1
  • STEP 6: REPEAT STEP 7 UNTIL j is less than or equals to i
  • STEP 7: PRINT i*j and SET j = j + 1
  • STEP 8: PRINT new line
  • STEP 9: SET i = i + 1
  • STEP 10: EXIT

Solution:

C Program:

Output:

 1
 2  4
 3  6  9
 4  8 12 16
 5 10 15 20 25
 6 12 18 24 30 36
 7 14 21 28 35 42 49
 8 16 24 32 40 48 56 64
 9 18 27 36 45 54 63 72 81
10 20 30 40 50 60 70 80 90 100

Java Program:

Output:

1 
2 4 
3 6 9 
4 8 12 16 
5 10 15 20 25 
6 12 18 24 30 36 
7 14 21 28 35 42 49 
8 16 24 32 40 48 56 64 
9 18 27 36 45 54 63 72 81 
10 20 30 40 50 60 70 80 90 100 

C# Program:

Output:

1 
2 4 
3 6 9 
4 8 12 16 
5 10 15 20 25 
6 12 18 24 30 36 
7 14 21 28 35 42 49 
8 16 24 32 40 48 56 64 
9 18 27 36 45 54 63 72 81 
10 20 30 40 50 60 70 80 90 100

PHP Program:

Output:

1 
2 4 
3 6 9 
4 8 12 16 
5 10 15 20 25 
6 12 18 24 30 36 
7 14 21 28 35 42 49 
8 16 24 32 40 48 56 64 
9 18 27 36 45 54 63 72 81 
10 20 30 40 50 60 70 80 90 100

Python Program:

Output:

 1
 2  4
 3  6  9
 4  8 12 16
 5 10 15 20 25
 6 12 18 24 30 36
 7 14 21 28 35 42 49
 8 16 24 32 40 48 56 64
 9 18 27 36 45 54 63 72 81
10 20 30 40 50 60 70 80 90 100





Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA