Program to find the maximum (or minimum) element of an array

using System;public class Codemirror{
static public void Main (){
//Code

int[] arr = {11, 12, 5, 9, 16, 56, 8};
int max = 0;
for(int i = 0; i < arr.Length; i++)
{
if(i==0)
{
max = arr[i];
}

if(max < arr[i] )
{
max = arr[i];
}
}
Console.WriteLine("Maximum element is: " + max);

}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store