Table of Contents
Write a Java program that takes a number as input and prints its multiplication table up-to 10.
This practical help us to understand working of for loop in java. Save this java program with name same as the class name which contains main() method i.e. Multiplyimport java.util.Scanner; //Author -> ITVoyagers, visit -> itvoyagers.in class Multiply { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("nPlease enter any number : "); int n = s.nextInt(); System.out.println("nnMultiplication Table of " + n); //Author -> ITVoyagers, visit -> itvoyagers.in for(int i=1; i<=10; i++) { System.out.println("n" + n + " x " + i + " = " + n*i); } System.out.println("nn"); //Author -> ITVoyagers, visit -> itvoyagers.in } }
Output :
Please enter any number : 4 Multiplication Table of 4 4 x 1 = 4 4 x 2 = 8 4 x 3 = 12 4 x 4 = 16 4 x 5 = 20 4 x 6 = 24 4 x 7 = 28 4 x 8 = 32 4 x 9 = 36 4 x 10 = 40