Preview:
#include <iostream>
using namespace std;
int const MAX = 60;
int maxinlst(int arr[], int sizeofArr); 

int main()
{
    int arr[MAX];
    int sizeofArr, currNum, maximum;

    cout << "Enter the size of the array " << endl;
    cin >> sizeofArr;
    cout << "Enter the list of numbers" << endl;
    for (int i = 0; i < sizeofArr; i++) {
        cin >> currNum;
        arr[i] = currNum;
    }

    maximum = maxinlst( arr,sizeofArr);
    cout << "The maximum is " << maximum << endl;


    return 0;
}

int maxinlst(int arr[], int sizeofArr) {

    int max = arr[0];
    for (int i = 1; i < sizeofArr; i++) {
        if (arr[i] > max) {
            max = arr[i];
        }
    }
    return max;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter