Q:

Write a program to print the following pattern

belongs to collection: Pattern Programs

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

C Program:

#include <stdio.h>  
int main()  
{  
  int lines=10;  
  int i=1;  
  int j;  
    for(i=1;i<=lines;i++){// this loop is used to print lines  
        for(j=1;j<=i;j++){// this lop is used to print the table of the i  
            printf("%d ",i*j);  
        }  
        printf("\n");  
    }  
    return 0;  
}  

 

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:

public class pattern{  
     public static void main(String[] args){  
    int lines=10;  
  int i=1;  
  int j;  
    for(i=1;i<=lines;i++){// this loop is used to print the lines  
        for(j=1;j<=i;j++){// this loop is used to print lines  
            System.out.print(i*j+" ");  
        }  
         System.out.println("");  
    }  
  }  
} 

 

 

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:

using System;  
public class Program  
{  
    public static void Main()  
    {  
    int lines=10;  
  int i=1;  
  int j;  
    for(i=1;i<=lines;i++){// this loop is used to print the lines  
        for(j=1;j<=i;j++){// this loop is used to print lines  
            Console.Write(i*j+" ");  
        }  
        Console.WriteLine("");  
    }  
    }  
}  

 

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:

<?php  
$lines=10;  
$i=1;  
$j;  
    for($i=1;$i<=$lines;$i++){// this loop is used to print lines  
        for($j=1;$j<=$i;$j++){// this loop is used to print lines  
            echo $i*$j;  
            echo " ";  
        }  
        echo "<br>";  
    }  
?>

 

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:

lines=10  
i=1  
j=1  
while i<=lines: # this loop is used to print the lines  
    j=1  
    while j<=i:  # this loop is used to print lines  
        temp=i*j  
        print(temp, end='', flush=True)  
        print(" ", end='', flush=True)  
        j=j+1;  
    print("");  
    i=i+1;  

 

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a program to print the following pattern... >>
<< Write a program to print the following pattern...