Loading
Data-structure-with-JAva-Tutorial

Minimum

Example:

package com.quipohouse;

import java.util.Scanner;
public class Main
{
  public static void main (String[]args)
  {

    System.out.println ("Finding minimum number");

    System.out.println ("Enter array size");
    Scanner input1 = new Scanner (System.in);
    int num1 = input1.nextInt ();

    int[] arr = new int[10];
    System.out.println ("Enter array values");
 
    for (int i = 0; i < num1; i++)
    {
        
	arr[i] = input1.nextInt ();
	
    }
      
    int min = arr[0];
    
    int ans=MinValue(arr,min,num1);
    System.out.println ("Min value is = " + ans);
   
  }
  
  public static int MinValue(int[] arr,int min ,int num1)
  {
    for (int j = 0; j < num1; j++)
    {
      
	if (arr[j] < min)
	  {
	    min = arr[j];
	  }
    }
    return min;
    
  }
}

Output:

Finding minimum number
Enter array size
5
Enter array values
1
2
25
0
2
Min value is = 0