Professional Documents
Culture Documents
h>
#include<stdlib.h>
int getMax(int arr[], int n){ // A function to get maximum value in array arr[];
int max = arr[0]; //don't forget to initialise the value of max, either
this way or initialize it with a number lower than the minimum of the given array
for (int i = 1; i < n; i++){
if (arr[i] > max){
max = arr[i];
}
}
return max;
}
int main(){
int arr[] = {170, 45, 75, 90, 802, 24, 2, 66};
int n = sizeof(arr)/sizeof(arr[0]); // sizeof(arr)=8*4 Bytes (
(size of the array) * (size of each element) )