[ create a new paste ] login | about

Link: http://codepad.org/Y6oXRlOf    [ raw code | output | fork ]

C++, pasted on Mar 1:
#include <iostream>

using namespace std;
//*****************************DECLARATION ARRAY*******************************************

int lastLargestIndex(int [], int);

int main()

{
    int arr[15] = {5,198,76,9,4,2,15,8,21,34,99,3,6,13,11111};
    int location;
    location = lastLargestIndex(arr, 15);
        cout << "The last largest index is:" << location << endl;
 return 0;
}

//*****************************LOOPS INTO FOR LARGEST OCCURANCE*******************************************

int lastLargestIndex(int arr[], int size)

{
    int lastLargestIndex = 0;
    int tem = arr[0];
    int i;
    for(i = 0; i < size; i++)
    {
        if (arr[i] > tem)
        {
            lastLargestIndex = i;
            tem = arr[i];
        }
    }
    return lastLargestIndex;
}


Output:
1
The last largest index is:14


Create a new paste based on this one


Comments: