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.
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);
}
}
}
Output:
$ javac Multiplication_Table.java $ java Multiplication_Table Enter number:7 7 * 1 = 7 7 * 2 = 14 7 * 3 = 21 7 * 4 = 28 7 * 5 = 35 7 * 6 = 42 7 * 7 = 49 7 * 8 = 56 7 * 9 = 63 7 * 10 = 70
Sanfoundry Global Education & Learning Series – 1000 Java Programs.
advertisement
Here’s the list of Best Books in Java Programming, Data Structures and Algorithms.
Related Posts:
- Practice Information Technology MCQs
- Practice Programming MCQs
- Apply for Java Internship
- Check Programming Books
- Practice BCA MCQs