Indexing an Array

I have the Array Indexed Variables written out as a second for loop in my program. What I want my code to do is find the max out of ten Arrays and then point to the Index.

Here are the lines of my code
1
2
3
4
5
6
7
8
for (int b = 0; b == 10; b++)
    {
       if (numbers[b] == max)
       max = numbers[b];
    }

     cout << "The max number is " << max << endl;
     cout << "The index number is " << numbers[b] << endl;


I already have max set up correctly for the maximum value. The issue is I keep getting my Index pointer to point to the last Array
That for will never be run (as the condition is initially false), and even if it did, it wouldn't do anything as you only perform an assignment if the two operands are already equal. So honestly, I can't see how max is getting a useful value at all.
They are equal what I'm trying to do is, cout the number like say in the array 1,2,3,4,5,6 and the max number is from array 5, then I want it to cout number[5]

EDIT: have the max number=(say 72) 72
then have the Index pointing to which integer index 72 is from. Hopefully that is explains what I'm trying to do better
Last edited on
The programming I used for finding int max is

int max = 0;
for (int i = 0; i < 10; i++)
    {
        if (numbers[i] > max)
        max = numbers[i];
    }
Instead of having 'max' store the maximum value, just have it store the index of the max value. Then write out 'max' as the index and 'numbers[max]' as the value.
Topic archived. No new replies allowed.