Skip to content

Commit 241fbde

Browse files
committed
feat: Find maximum of three numbers using nested if-else
🧠 Logic: - Compare three integers `a`, `b`, and `c`. - If `a` is greater than both `b` and `c`, print `a`. - Else, check if `b` is greater than `c`, then print `b`. - If neither `a` nor `b` is the greatest, then `c` must be the maximum, so print `c`. Signed-off-by: Somesh diwan <[email protected]>
1 parent 0165a42 commit 241fbde

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

Section8LoopAB/Loop 2.O/src/NestedIFAB.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ public class NestedIFAB {
44
public static void main(String[] args) {
55
int a = 5, b = 6, c = 10;
66

7-
if(a > b && a > c)
8-
{
7+
if(a > b && a > c) {
98
System.out.println(a);
10-
} else if (b > c)
11-
{
9+
} else if (b > c) {
1210
System.out.println(b);
1311
}
14-
else
15-
{
12+
else {
1613
System.out.println(c);
1714
}
1815
}
19-
}
16+
}

0 commit comments

Comments
 (0)