codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#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; }
Private
[
?
]
Run code
Submit