In this post we will see how to print table of number in java.
It is good program to practice for loop in java.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import java.util.Scanner; public class TableOfNumber { public static void main(String args[]){ int number, i, table; Scanner scan = new Scanner(System.in); System.out.print("Enter a Number : "); number = scan.nextInt(); System.out.print("Table of " + number + " is\n"); for(i=1; i<=10; i++){ table = number*i; System.out.print(number + " * " + i + " = " + table + "\n"); } } } |
Output:
- Looking for ⚒️ tech jobs? Go to our job portal.
- Looking for tech events? Go to tech events 🗓️ Calendar.️
Table of 8 is
8 * 1 = 8
8 * 2 = 16
8 * 3 = 24
8 * 4 = 32
8 * 5 = 40
8 * 6 = 48
8 * 7 = 56
8 * 8 = 64
8 * 9 = 72
8 * 10 = 80
That’s all about how to print table of number in java.