max element in array c code example
Example 1: max value of array in c
// storing the largest number to arr[0]
for (int i = 1; i < n; ++i) {
if (arr[0] < arr[i]) {
arr[0] = arr[i];
}
}
Example 2: max element in array
int max;
max=INT_MIN;
for(int i=0;i<ar.length();i++){
if(ar[i]>max){
max=ar[i];
}