Java Program to print Multiplication Table of any Number - The Coding Shala
Home >> Java Programs >> Print Multiplication Table in Java
Other Posts You May Like
In this post, we will learn How to Generate a Multiplication Table of any Number using a Java Program.
Java Program to Print Multiplication Table of any Number
We will take a number input from the user and will generate a multiplication table of that number using Java loops. We can use for loop or while loop here. The Java Program of Multiplication Table is below:
Java Program:
/** * https://www.thecodingshala.com/ */ import java.util.*; public class Main { public static void printTable(int num) { for(int i = 1; i <= 10; i++) { System.out.println(num + " * " + i + " = " + num*i); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter a number"); int num = sc.nextInt(); printTable(num); } }
Output:
Enter a number 9 9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 9 * 6 = 54 9 * 7 = 63 9 * 8 = 72 9 * 9 = 81 9 * 10 = 90
- Java Program to Find the Area of a Triangle
- Java Program to Calculate Average of an Array
- Java Program to Calculate Simple Interest
- Java Program to Calculate Power of a Number
- Java Program to Check if a Number is a Palindrome
Comments
Post a Comment