This program code describe how to find minimum in an array



Program Code :




import java.util.Scanner;
public class Array_Min {

public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
int n,min,location=1;
int a[]=new int[100];
System.out.println("Enter the number of integer in array =");
n=scn.nextInt();
System.out.println("Input "+n+" integer");
for(int i=1;i<=n;i++){
a[i]=scn.nextInt();
}
min=a[1];
for(int i=1;i<=n;i++)
if(a[i]<min)
{
min=a[i];
location=i;
}
System.out.println("Minimum is "+min+" at position "+location);
}

}



Output :

 Enter the number of integer in array =
5
Input 5 integer
48
57
24
09
49
Minimum is 9 at position 4


 
Top