C program to find largest element of an array

#include<stdio.h>
#define MAX 50 

int main( )

{
  int arr[MAX], n, i, max;

   printf("Number of elements");

   scanf("%d",&n);

   printf("Enter elements of array");


   for(i=0; i<n; i++)

     scanf("%d",&arr[i]);

   max=arr[0];


   for(i=1; i<n; i++)

    {
        if(arr[i]>max)
            max=arr[i];

    }


  printf("maximum element of array is %d",max);


return 0;

}



Post a Comment

0 Comments