C Program to find largest element in array

Simple C program to find largest element in array.
#include<stdio.h>
#include<limits.h>
int main()
{
 int arr[8]={3,7,2,9,6,3,12,1};
 int max=INT_MIN,i,n=sizeof(arr)/sizeof(arr[0]);
 for(i=0;i<n;i++)
 {
  if(max<arr[i])
  {
  max=arr[i];
 }
 }
 printf("Largest element in array = %d",max);
 
 return 0;
}


Popular posts from this blog