Java program to print table using for loop

In this article we are going to print any table using for loop.

Steps:-

  • First take number from user using scanner.
  • Run a for loop from i=1 to i=10.
  • print number*i.

Java code to print table using for loop:-

package gangforcode;
import java.util.*;
public class Table {
 public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.println("Enter the no");
		int n= sc.nextInt();
		for(int i=1;i<11;i++) {
			System.out.println(i*n);
		}}}

Output:-

java program to print a table

Thanks

Leave a Comment