Find the Largest Number in an Array

Given an array, Find the Largest Number in an Array.

For example:

If the input array is 

1 2 3 4 5

then the largest number in the array is "5".

Implementation:

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
int main(void) {
 
 /* store the minimum value of signed integer in max which is -2147483648 */
 int *a,n,i,max=INT_MIN;
 
 /* Get the number of elements of the array */
 scanf("%d",&n);
 
 /* allocate the size of n integers */
 a=(int*)malloc(sizeof(int)*n);
 
 /* Get the integers from the user, thereby store the update the maximum element of the array every time */
 for(i=0;i<n;i++)
 {
  scanf("%d",(a+i));
  max=max>*(a+i)?max:*(a+i);
 }
 
 /* Print the largest element which is max */
 printf("greatest element is %d",max);
 
 return 0;
}