Display the minimum value of elements in an array





 public class MainClass


PROGRAM:
{
public static void main(String[] args) throws IOException { int[] list = {5, 6, 7, 8, 1, 2, 5, -7, -9, 2, 0}; int min = list[0]; for (int i = 1; i < list.length; i++) { if (list[i] < min) min = list[i]; } System.out.println ("Minimum is " + min); } }
OUTPUT:
Minimum is -9

Comments

Popular posts from this blog

Automation using selenium and python/java interview question to order a product in e commerce website.

Basic details while learning MY SQL:

Display numbers 1 to 10 using array