-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDo_While_Loop.java
More file actions
26 lines (22 loc) · 1012 Bytes
/
Do_While_Loop.java
File metadata and controls
26 lines (22 loc) · 1012 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: Do-While Loop Demo
* Description: A Java program to demonstrate the 'do-while' loop by printing a multiplication table.
* The do-while loop executes the block of code at least once before checking the condition.
* Author: Amey Thakur
* Reference: https://github.com/Amey-Thakur/OOPM-JAVA-LAB
*/
public class Do_While_Loop {
public static void main(String[] args) {
int num = 5;
int c = 1;
System.out.println("---------------------------------------------");
System.out.println(" Do-While Loop Demo");
System.out.println("---------------------------------------------");
System.out.println("Printing table of " + num + " using do-while loop:");
do {
System.out.println(num + " X " + c + " = " + (num * c));
c++; // Increment counter
} while (c <= 10); // Condition is checked after execution
System.out.println("---------------------------------------------");
}
}