Answers for "index of max element in array c++ with function"

C++
13

max element in array c++ stl

*max_element (first_index, last_index);
ex:- for an array arr of size n
*max_element(arr, arr + n);
Posted by: Guest on May-21-2020
0

Find the max element along with it's index in c++

int main()
{
    int num, arr[10];
    int x, y, a, b;

    cin >> num;

    for (int i = 0; i < num; i++)
    {
        cin >> arr[i];
    }

    cout << "Max element Index: " << max_element(arr, arr + num) - arr;

    return 0;
}
Posted by: Guest on July-08-2021

Code answers related to "index of max element in array c++ with function"

Browse Popular Code Answers by Language