input value get index

hello all,
im trying to get the index of a value by inputting the value:
for example if i have
1
2
3
int arr[5]={22, 85, 58, 78, 69};

indexOfItem(arr, 78);


and have the output be:


the index of the item is: 3


thanks in advance!!
so
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void indexOf(int arr[], int lenght){  
	int temp=0;
	int e;
	for (int i = 0; i < lenght; i++)
	{
		if (arr[i]>temp){
			temp = arr[i];
			e = i;
		}

	}
	cout << "the index is : " << e << " and the value is : " << temp << endl;
   }

// arr[] is your array and length is the length of the array  



ok i figured it out! this is the answer!
If you refuse to use existing algorithms and insist on reinventing them yourself, you are prone to errors.
Topic archived. No new replies allowed.