#including<iostream>
using namespace std;
int array[10]={3,5,2,7,8,4,6,7,4,11};
int findMax()
{
int length=array.length();
int max;
int count;
for(int i=0;i<length;i++)
{
count+=1
if(array[i]>max)
max=array[i];
}
return max;
}
int main()
{
findMax(array[10]);
}
int findMax() {
int length = (sizeof(array) / sizeof(int)); // Initialized a variable to get the size of the array[]
int max = 0; // Initilized max, if you use an uninitialized variable you'll get an error
for (int i = 0; i < length; i++) {
if (array[i] > max) { // Checked if the current array number is bigger than 0
max = array[i]; // If True, change value of max to the current number in array
}
}
return max; // Return the biggest number in array[]
}

#include <iostream>>
using namespace std;
int findMax(int array[], int length);
int main() {
int array[10] = { 3, 5, 2, 7, 8, 4, 6, 7, 4, 11 };
int length = (sizeof(array) / sizeof(int)); // Getting the size of the array
int maxNum = findMax(array, length); // Since the function returns a variable, you need something to hold the variable
// Passed the array[] and length variable as argument to the function
cout << maxNum << endl; // Display the max value returned
return 0;
}
int findMax(int array[], int length) { // Pass an array and a length variable as parameter
int max = 0;
for (int i = 0; i < length; i++) {
if (array[i] > max) {
max = array[i];
}
}
return max;
}
