Java program to print table of n number from given range m to n.
import java.util.Scanner;
public class TableFromMtoN{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the range of numbers from m to n for the multiplication table: ");
int m = scanner.nextInt();
int n = scanner.nextInt();
if(m<=n){
int x=m;
while(x<=n){
System.out.println("Multiplication table for " + x + ":");
for (int i = 1; i <= 10; i++) {
int result = x * i;
System.out.println(x + " * " + i + " = " + result);
}
x++;
}
}
else{
System.out.println(" Numbers Range is Wrong,try Again");
}
}
}
Comments
Post a Comment