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:
Enter a Number : 8
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
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.
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.