← All resources

Write a program to input an array of size N and print the minimum value

import java.io.*;
public class array_min
{
    public static void main()throws IOException
    {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        int n, a[], i, min;
        System.out.println("Enter the size of the array:");
        n = Integer.parseInt(r.readLine());
        a = new int[n];
        System.out.println("Enter the values of the array:");
        for(i=0;i < n;i++)
        {
            a[i] = Integer.parseInt(r.readLine());
        }
        min = a[0];
        for(i=1;i < n;i++)
        {
            if(min>a[i])
            min = a[i];
        }
        System.out.println("The maximum values is:"+min);
    }
}