Thursday, September 26

Multiplication table generation using Java (natural numbers up to 20)

Hi ALL,

I wrote a program for Multiplication table generation using java looping concept (natural numbers up to 20).

public class tables{ 

public static void main(String args[])
 {    
   
    for(int i = 1; i <=20; i++) {
        System.out.println("\n\n"+i +" table\n");
        for(int j = 1; j <= 20; j++) {
            System.out.println(j+" *"+i+" ="+(i*j));
        }               
    }
    
 }

}


OUTPUT:

1 table

1 *1 =1
2 *1 =2
3 *1 =3
4 *1 =4
5 *1 =5
6 *1 =6
7 *1 =7
8 *1 =8
9 *1 =9
10 *1 =10
11 *1 =11
12 *1 =12
13 *1 =13
14 *1 =14
15 *1 =15
16 *1 =16
17 *1 =17
18 *1 =18
19 *1 =19
20 *1 =20


2 table

1 *2 =2
2 *2 =4
3 *2 =6
4 *2 =8
5 *2 =10
6 *2 =12
7 *2 =14
8 *2 =16
9 *2 =18
10 *2 =20
11 *2 =22
12 *2 =24
13 *2 =26
14 *2 =28
15 *2 =30
16 *2 =32
17 *2 =34
18 *2 =36
19 *2 =38
20 *2 =40


3 table

1 *3 =3
2 *3 =6
3 *3 =9
4 *3 =12
5 *3 =15
6 *3 =18
7 *3 =21
8 *3 =24
9 *3 =27
10 *3 =30
11 *3 =33
12 *3 =36
13 *3 =39
14 *3 =42
15 *3 =45
16 *3 =48
17 *3 =51
18 *3 =54
19 *3 =57
20 *3 =60


4 table

1 *4 =4
2 *4 =8
3 *4 =12
4 *4 =16
5 *4 =20
6 *4 =24
7 *4 =28
8 *4 =32
9 *4 =36
10 *4 =40
11 *4 =44
12 *4 =48
13 *4 =52
14 *4 =56
15 *4 =60
16 *4 =64
17 *4 =68
18 *4 =72
19 *4 =76
20 *4 =80


5 table

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
11 *5 =55
12 *5 =60
13 *5 =65
14 *5 =70
15 *5 =75
16 *5 =80
17 *5 =85
18 *5 =90
19 *5 =95
20 *5 =100

etc upto 20th table


No comments:

Post a Comment

Backup files to google drive using PHP coding

 Dear All, To backup files to Google Drive using PHP coding, you can use the Google Drive API and the Google Client Library for PHP. Here...