building an array project - error message error C2660: 'FindAvg' : function does not take 1 parameters
This is the only error message I have left to fix. I've tried everything I can think of. Please help!
Here is where it points the error message too:
//find the average of numbers in array a
float Average;
FindAvg(a);
this is the related user defined function:
void FindAvg(int a[])
{
int Total = 0;
for (int i = 1; i < 10; ++i)
{
Total += a[i];
}
float Average = Total/10;
}
If more information is needed, please let me know.
Thanks, anyone who can help!
Thanks! I will give this a try. Also, thanks for including "why" I need to write it that way. It's difficult to get help from my classmates! I think they want to keep all the information to themselves! Hahaha! Or I just need to reconsider my major, this is some very difficult stuff! :-)
Forum Rules/Features
Welcome to the WiBit.net forums! Check out our terms and features:
Hot Topic(s)
Annoy your friends
Is this something you think someone else would enjoy? Is it not for you, but do you know someone who is down with this type of content? Well share away:
Tweet
The Blog
Don't Let XML Make You a Cheater
This blog is a reminder that cheating in software development can get you into big trouble. Sometimes developers get really really lazy, OR are pressured to write something using overly simplified data structures. Almost every time this happens you are bitten in the butt! Sometimes the problems show up immediately and other times it may take months or years (especially in integrated systems).
- 1 of 78
- ››








The required parameter for FindAvg is an array of intergers. You are passing a single float. The problem is that you are passing the wrong type of argument.
this should work
#include "stdio.h" ////// I wrote this in C, but this function will work in a C++ program too
float FindAvg(float a[], int size) /// you need to specify how many elements are in the array
/// I also would expect that you want to return the average so that's why I have it return a float
{
float Total = 0.0;
int i;
for (i = 0; i < size; i++) /// arrays start at 0 not 1 /// also use the postincrement operator "i++" instead
{
Total += a[i];
}
float Average = Total/size;
return Average;
}
int main()
{
float myNumbers[] = { 1.2, 2.3, 3.4 }; ////// you can change and/or add values
printf("%f\n",FindAvg(myNumbers, sizeof(myNumbers)/sizeof(float))) ;
return 0; // the sizeof operator tells how many bytes something takes up in memory
/// so if you take the total number of bytes in the elemetns take up and divide that number
/// by the size of each element, then you get the number of elements
}