Skip to content

Commit 24f6888

Browse files
committed
feat: Display multiplication table of a user-entered number using for-loop
🧠 Logic: - Take integer input `n` from the user. - Use a `for` loop from 0 to 10 to print the multiplication table. - On each iteration, print the formatted result: `n x i = product`. Signed-off-by: Somesh diwan <[email protected]>
1 parent 9fa4986 commit 24f6888

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Section8LoopAB/src/ForLoopAB3.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
import java.util.Scanner;
44

55
public class ForLoopAB3 {
6-
public static void main(String[] args)
7-
{
6+
public static void main(String[] args) {
87
Scanner sc = new Scanner(System.in);
98
System.out.println("Enter a Number");
10-
int n = sc.nextInt();
119

12-
for(int i = 0; i<=10; i++){
10+
int n = sc.nextInt();
11+
for(int i = 0; i<=10; i++) {
1312
System.out.println(n+" x "+i+" = "+ n*i);
1413
}
1514
}

0 commit comments

Comments
 (0)