Multiplication Table in Java Using For Loop

Multiplication table in java. In the Java application, print the mathematics tables. As a novice in the Java programming language, this software is even more impressive and expands the programming ideas. The method of obtaining a product by combining matrices, vectors, or other quantities according to particular laws.

For Loop in Java Program

A for loop is a repetition control structure that allows you to construct a loop that must be repeated a certain number of times quickly. When you know how many times a task will be repeated, a for loop comes in handy. A “For” Loop is used to repeat a block of code for a certain number of times. If we wish to verify every student’s grade in the class, for example, we loop from 1 to that number.

Scanner in Java Program

The scanner is a class in the Java util package that is used to get the input of primitive kinds such as int, double, and strings. It’s the simplest way to read input in a Java program, but it’s inefficient if you need an input method for situations where speed is a factor, such as competitive programming.

import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
int number, i, tab;
Scanner scan = new Scanner(System.in);
System.out.print("Enter a numbers");
number = scan.nextInt();
System.out.print("Table of " + number + " is\n");
for(i=1; i<=5; i++)
{
tab = number*i;
System.out.print(tab + "\n");
}
}
}

Output:

Enter a numbers
2
Table of 2 is
2
4
6
8
10