on Leave a Comment

Java Program to Print Multiplication Table of a Number

This java program generates multiplication table of a given number. First you have to enter a number and then multiply that number from 1 to 10 using for loop and then print multiplication table of that number. 

Java Program to Generate Multiplication Table

import java.util.Scanner;
class MultiplicationTable
{
 public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  System.out.print("Enter a Number : ");
  int n = sc.nextInt();
  System.out.println("Multiplication Table of "+n+" :");
  for(int i = 1; i<=10; i++)
   System.out.println(n+" * "+i+" = "+n*i);
 }
}

Output:


Enter a Number : 10
Multiplication Table of 10 :
10 * 1 = 10
10 * 2 = 20
10 * 3 = 30
10 * 4 = 40
10 * 5 = 50
10 * 6 = 60
10 * 7 = 70
10 * 8 = 80
10 * 9 = 90
10 * 10 = 100

0 comments:

Post a Comment