Skip to content

Commit 413acc9

Browse files
committed
feat: Print powers of 2 using do-while loop until less than 100
🧠 Logic: - Initialize `i = 1`, then use a `do-while` loop to print and double `i` on each iteration. - Loop continues while `i < 100`, resulting in values: 1, 2, 4, 8, 16, 32, 64. - Demonstrates guaranteed execution at least once using `do-while`. Signed-off-by: Somesh diwan <[email protected]>
1 parent 18dfb91 commit 413acc9

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Section8LoopAB/src/DoWhileLoop.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
public class DoWhileLoop {
22
public static void main(String[] args) {
33
int i = 1;
4-
do
5-
{
4+
do {
65
System.out.println(i);
76
i=i*2;
87
}

0 commit comments

Comments
 (0)