This is my full code:
<pre>
#include <iostream>
#include <algorithm>
using namespace std;
float compute_avewil(const int low_value[30], const int high_value[30])
{
float average_value[30];
for(int i=0;i<30;i++) {
average_value[i] = low_value[i] + high_value[i];
average_value[i] = average_value[i] / 2;
}
for(int i=0;i<30;i++) {
cout << average_value[i] << " ";
}
cout << endl;
return 0;
}
int find_highthat(float average_value[30])
{
int maxex = 0;
float max = average_value[maxex];
for(int i=1;i<30;++i)
{
if(max<average_value[i])
{
maxex = i;
max = average_value[i];
}
}
cout << endl;
return maxex;
}
int main(float average_value[30])
{
int id_number[30] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 };
int high_value[30] = { 10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300 };
int low_value[30] = { 1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1,0,1,2,3,4,5,4,3,2,1,0 };
compute_avewil(low_value, high_value);
find_highthat(average_value);
}
The Exception thrown issue comes in at:
int find_highthat(float average_value[30])
{
int maxex = 0;
float max = average_value[maxex];
for(int i=1;i<30;++i)
{
if(max<average_value[i])
{
maxex = i;
max = average_value[i];
}
}
cout << endl;
return maxex;
}
Specifically the line:
float max = average_value[maxex];
I thought this was weird since this function seemed ok to me. I searched up similar problems, I knew what the meaning of the problem was but my code seemed fine, so I do not see the problem nor do I know any solution for it.
What I have tried:
I tried searching up what's wrong, I get what the problem it self means but I still have not fix it since I don't know any solutions and the function itself seems ok to me.