Multiplication Table in Java: Explanation & Practice
Print multiplication table for a number
Problem summary
Print the multiplication table for 5 (5x1 through 5x5).
Starter code
public class Main {
public static void main(String[] args) {
int num = 5;
// Print: 5 x 1 = 5, 5 x 2 = 10, etc.
}
}Expected output and test cases
- 5x table (1-5)
5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25
Hints
- Use a for loop from 1 to 5
- Calculate product: num * i
- Print in format: num x i = product
Related Control Flow exercises
- Practice Print Numbers 1-5 in Java
- Practice Print Even Numbers in Java
- Practice Prime Number Check in Java
Practice all Control Flow exercises · Run this idea in the Java compiler