We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
import java.util.*;
public class Table{
public static void main (String[] args) {
int b=0;
Scanner sc = new Scanner(System.in);
System.out.println("enter the number");
int a = sc.nextInt();
System.out.println("enter the range");
int r = sc.nextInt();
for( int i=1;i<=r;i++){
b=a*i;
System.out.println(a+" x " + i +" = " +b);
// System.out.printf("%d * %d = %d \n" a,i,a*i); this can aslo be used for printing our output
}
}
Java Loops I
You are viewing a single comment's thread. Return to all comments →
import java.util.*; public class Table{ public static void main (String[] args) { int b=0; Scanner sc = new Scanner(System.in); System.out.println("enter the number"); int a = sc.nextInt(); System.out.println("enter the range"); int r = sc.nextInt(); for( int i=1;i<=r;i++){ b=a*i;
}