cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Average value of some data
Average value of some data
Oct 18, 2018 at 4:50pm UTC
Niksy50
(4)
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;
}
Oct 18, 2018 at 5:21pm UTC
MikeyBoy
(5631)
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.