Q:

Write a Java program to print multiplication table of given number using loop

0

Write a Java program to print multiplication table of given number using loop

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..

import java.util.Scanner;
 
public class JavaLoopExcercise
{
    public static void main(String[] args)
    {
        Scanner console = new Scanner(System.in);
        int num;
 
        System.out.print("Enter any number: ");
        num = console.nextInt();
 
        System.out.println("Multiplication Table of " + num);
 
        for(int i=1; i<=10; i++)
        {
            System.out.println(num +" x " + i + " = " + (num*i) );
        }
}

Result:

Enter any number: 5

Multiplication Table of 5

5 X 1 = 5

5 X 2 = 10 

5 X 3 = 15 

5 X 4 = 20 

5 X 5 = 25 

5 X 6 = 30 

5 X 7 = 35 

5 X 8 = 40 

5 X 9 = 45 

5 X 10 = 50

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a Java program to find the factorial value o... >>
<< Write a java program to calculate the sum of first...