Average value of some data

Hi, i must calculate arithmetic average value of some data, but when i run my program it doesn't give me any value.

float arithmetic_average_value (int b[],int c[]) {
int sum=0;
size_t N = sizeof(b)/sizeof(b[0]);
for(int i=0;i<N-1;i++){
sum = sum+b[i]+c[i];
}
float aav = (float) sum/N;
return aav;
}
int main()
{
int a1[] = {17,6,6,1,5,2,3,1};
int a2[] = {24,12,7,15,4,4,9,5};
cout << arithmetic_average_value(a1,a2);
return 0;
}
You should try stepping through your code with a debugger, examining the values of your variables. That would give you some valuable - and, perhaps, surprising - information on what's going on and why it's going wrong.

Try it - it will be instructive!
Topic archived. No new replies allowed.