"KEEP LEARNING, DON'T STOP."
"KEEP LEARNING, DON'T STOP."
In this section you will learn how to print a table of given number. Here we will apply multiplication operation to print the table. We will take the input from user.
Scanner function is use to take the input from user in java.
import java.util.Scanner; class Table { public static void main(String arg[]) { int i, n, sum; Scanner sc = new Scanner(System.in); System.out.println("ENTER A NUMBER TO PRINT A TABLE:- "); n = sc.nextInt(); for(i=1; i<=10; i++) { sum=i*n; System.out.println(sum); } } }
ENTER A NUMBER:- 5 5 10 15 20 25 30 35 40 45 50
Advertisment