Java Online Compiler
Example: Multiplication Table in Java Program using For loop
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// Multiplication Table in Java Program using For loop import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int x, r, i; // x - To store the input number // r - To store the multiplication range System.out.println ("----Enter the input number is::---\n"); x = in.nextInt(); System.out.println ("\n----Enter the range number is::----\n"); r = in.nextInt(); System.out.println ("\n\n------The above multiplication table--------\n\n"); for (i = 1; i <= r; i++) { System.out.print (x + " * " + i + " = " + (x * i) + "\n"); } } }
13 12
Output
Clear
ADVERTISEMENTS