#include <iostream>
using namespace std;

int& maxElement(int arr[], int size){
    int maxEle = 0;
    for (int i = 0; i < size;i++) {
            if (arr[i] > arr[maxEle]) {
        maxEle = i;
    }
    }
    return arr[maxEle];
}

int main() {
    int arr[4] = {10,50,30,20};
    cout << maxElement(arr,4) <<endl;
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: