Program on Multiplication Table using for loop in Java.

Introduction:

Hii everyone, you must be tired of learning multiplication table. So stop searching for multiplication table on google and using a calculator.Since you are going to be a programmer, make your own stuff!.

Description Of Program:

The speciality of our program is we are going to make our program user flexible(user will be able to enter the required  number and up to which number we wanted to execute our table ), so we will use scanner and take to variables (a,b) and the variable we used here is in integer form you can also use double as data type.Then we are running a for loop which will run up to “b”, then print the output.                                                                                                                               Hope it would be helpful.

CODE:

 

import java.util.Scanner;

/**
*
* @author Sakshi
*/
public class Multiplicationtable {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println(“Enter the numbers”);
int a=s.nextInt();
int b=s.nextInt();
for(int i=1;i<=b;i++)
System.out.printf(“%s X %s = %s\n”,a,i,a*i);
}
}

 

2 thoughts on “Program on Multiplication Table using for loop in Java.”

Leave a Reply