FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 96   



Following program shows you how to print table for given number.
In this program we get number from user and print that number table using for loop

import java.util.Scanner;

public class BasicMath4 {

    public static void main(String[] args) {

        System.out.println("Enter the number:");

        Scanner in = new Scanner(System.in);
        int input = in.nextInt();

        for (int i = 1; i <= 10; i++) {
            System.out.println(input + " * " + i + " = " + input * i);
        }
    }
}

Output:

Enter the number:
3

3 * 1 = 3
3 * 2 = 6
3 * 3 = 9
3 * 4 = 12
3 * 5 = 15
3 * 6 = 18
3 * 7 = 21
3 * 8 = 24
3 * 9 = 27
3 * 10 = 30



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News