Quote:
Can someone please help me with this code? I don't know why it isn't working?
Learn to help yourself ! The compiler gives you tons of hints, learn to use them.
Quote:
In function 'int main()':
61:55: error: expected primary-expression before ']' token
In function
main() line
61 position
55
cout << "Median rate is " << findMedian(MAX_RATES[], numRates) << endl;
^ this char
The compiler don't like it.
- Check what you are doing. '
[]' is used with arrays.
- What is
MAX_RATES ?
const int MAX_RATES = 20;
MAX_RATES is a global constant, not an array, the compiler don't understand what you try to do.
Nota: It is always a bad idea to use the same name for many things with a mixing of local and global defines, at least as a beginner.
Quote:
114:28: error: invalid types 'const int[int]' for array subscript
114:59: error: invalid types 'const int[int]' for array subscript
if (MAX_RATES[j] < MAX_RATES[index_of_smallest])
Here again, you use the integer constant like an array.