-
Notifications
You must be signed in to change notification settings - Fork 78
Expand file tree
/
Copy pathFindTheSmallest.java
More file actions
46 lines (44 loc) · 975 Bytes
/
FindTheSmallest.java
File metadata and controls
46 lines (44 loc) · 975 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.java.basic;
/*
* Find the Smallest of 3 (a,b,c) without using < or > symbol
* ----------------------------------------------------------
* Mostly to find max or min we use < or > symbol
* But here without using < or > symbol how to find smallest
*
* Use division operator to compare two compare
* a = 10 b = 20
* a/b == 0 -> this means a is smaller than b
* a = 20 b = 5
* b/a == 0 -> this means b is smaller than a
*
* This is the technique which we have to use to find the
* smallest of 3 (a,b,c)
*
*/
public class FindTheSmallest {
public static void main(String[] args) {
int a = 10;
int b = 5;
int c = 20;
if(a/b == 0 && a/c == 0)
System.out.println("a is the smallest");
else if(b/a == 0 && b/c == 0)
System.out.println("b is the smallest");
else
System.out.println("c is the smallest");
}
}
/*
INPUT
a = 10
b = 20
c = 5
OUTPUT
c is the smallest
INPUT
a = 10
b = 5
c = 20
OUTPUT
b is the smallest
*/