Java Program to generate Multiplication Table

In this java programming tutorial,we will learn how to create or generate a multiplication table of any number using command line argument. So, if you want to generate the multiplication table of any number, then just copy this java source code into your editor and compile it after that just run the java program and enter the number in command line whose multiplication table you want to generate as shown in the screenshot below.

Source Code of Java Program to generate the Multiplication Table

/* Program to Display Multiplication Table in Java programming language using command line argument */

class MultiplicationTable{

      public static void main(String args[]){

      int num = Integer.parseInt(args[0]);

      System.out.println("*****MULTIPLICATION TABLE*****");

      for(int i=1;i<=num;i++){

         for(int j=1;j<=num;j++){

            System.out.print(" "+i*j+" ");

         }

         System.out.print("\n");

      }

  }

}

Output of the Multiplication Table generation Java Program

0 comments:

Post a Comment