write a program to print the table of 5 in java
Answers
Explanation:
Menu
Java Program to Print Multiplication Table for any Number
« PrevNext »
This is a Java Program to Print Multiplication Table for any Number.
Enter any integer number as input of which you want multiplication table. After that we use for loop from one to ten to generate multiplication of that number.
Here is the source code of the Java Program to Print Multiplication Table for any Number. The Java program is successfully compiled and run on a Windows system. The program output is also shown below.
advertisement
import java.util.Scanner;
public class Multiplication_Table
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
System.out.print("Enter number:");
int n=s.nextInt();
for(int i=1; i <= 10; i++)
{
System.out.println(n+" * "+i+" = "+n*i);
}
}