-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathWhile_Loop.java
More file actions
26 lines (22 loc) · 909 Bytes
/
While_Loop.java
File metadata and controls
26 lines (22 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
* Program: While Loop Demo
* Description: A Java program to demonstrate the 'while' loop by printing a multiplication table.
* Author: Amey Thakur
* Reference: https://github.com/Amey-Thakur/OOPM-JAVA-LAB
*/
public class While_Loop {
public static void main(String[] args) {
int i = 1;
int num = 7;
System.out.println("---------------------------------------------");
System.out.println(" While Loop Demo");
System.out.println("---------------------------------------------");
System.out.println("Printing table of " + num + " using while loop:");
// Loop runs as long as i is less than or equal to 10
while (i <= 10) {
System.out.println(num + " X " + i + " = " + (num * i));
i++; // Increment counter
}
System.out.println("---------------------------------------------");
}
}