Java program to generate multiplication table

How to generate multiplication table in java?

In this program, we will understand the logic to print table and also implement that logic in java programs.

A table is a sequence of number that are generated using multiplication. We enter an integer as input of which we want to print the table. After that, we multiply the entered by 1 to 10, respectively on by one.

Suppose we have entered 5 as input then the table of 5 will be:

5*1 = 5
5*2= 10
5*3 =15

  • Program:

public class MultiplicationTable {

    public static void main(String[] args) {

        int num = 8;
        for(int i = 1; i <= 10; ++i)
        {
            System.out.printf("%d * %d = %d \n", num, i, num * i);
        }
    }
}

  • Output:

8 * 1 = 8 
8 * 2 = 16 
8 * 3 = 24 
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
8 * 10 = 80

  • Visit:

Java program to print an Integer Here
Java program to add two integers Here
Java program to find ASCII value of a character Here
Java program to compute quotient and remainder Here
Java program to swap two numbers Here
Java program to check whether a given number is even or odd Here
Java program to check whether an alphabet is vowel or consonant Here 
Java program to find the largest among three numbers Here
Java program to find all roots of a quadratic equation Here
Java program to check leap year Here
Write a java program to multiply two floating point numbers Here
Java program to check whether a number is positive or negative Here
Java program to check whether a character is alphabet or not Here
Java program to calculate the sum of natural numbers Here
Java program to find factorial of a number Here

0 comments