you could write getAvg() to use a variable number of arguments, but the std::vector is a lot better and easier to implement solution for c++ programs. There must be at least one non-variable argument. and you need to devise for that function to know where the last argument is -- maybe pass -1 or something else that will not occur normally in the other arguments. for variable arguments you need to use functions in stdarg.h . Scroll down the page of that link and you will find some example programs.

Code:
int getAvg(int a, ...);

int main()
{
   int n = getAvg(1,2,3,4,5,6,-1);
}