Printing the multiplication table upto the given Number using for the for loop. A for loop is a repetition control structure which allows us to write a loop that is executed a specific number of times. The loop enables us to perform n number of steps together in one line. The three components of the for loop (separated by ;) are variable declaration/initialization (i = 0), the condition ( i < n), and the increment statement ( i++).
import java.util.Scanner; //Write a program to print the multiplication tables public class multiplication { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter The Table : "); int t = in.nextInt(); System.out.print("Enter The Limit : "); int n = in.nextInt(); for(int i=1;i<=n;i++) { System.out.println(t + " x " + i + " = " + (t * i)); } } }
Enter The Limit : 10 7 x 1 = 7 7 x 2 = 14 7 x 3 = 21 7 x 4 = 28 7 x 5 = 35 7 x 6 = 42 7 x 7 = 49 7 x 8 = 56 7 x 9 = 63 7 x 10 = 70To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions