-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinimum.java
More file actions
36 lines (28 loc) · 802 Bytes
/
Minimum.java
File metadata and controls
36 lines (28 loc) · 802 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
import java.util.Scanner;
// DONE
public class Minimum
{
public static void main(String[] args)
{
Scanner obj = new Scanner(System.in); // for input
int [] a = new int[5]; // array of 5 elements
for (int i = 0; i < 5; i++) // input
{
System.out.print(" Enter the " + (i+1) + " Number : ");
a[i] = obj.nextInt();
}
int i = 1; // manual gear shifting
int smallest = a[0]; // array ki first value ko rakh
// dena behtar as 0 ya large value isn't suitable for memory
while (i < 5)
{
if (a[i] < smallest)
{
smallest = a[i];
}
i++;
}
// OUTPUT
System.out.println(" Smallest : " + smallest);
}
}