Hello,

I am a C++ student and am practicing for C++ test. I have been stuck on a program. If anyone could guide me a bit I would really appreciate it as this is my first programming class. We are studying pointers, and functions. Here info about this code and here is what I have done. We have to use this code with a function though. Thanks for any help anybody can give.

I am trying to solve a practice program in order to prepare for a test and have been stuck on it for hours. the program has to calculate the sum over a range of integers from LOWER to UPPER and return the average value. for example if the lower is 3 and the upper is 6, then the average would be (3+4+5+6)/4 or 4.5. I have to enter the upper and lower limits using in cin, also if you could also show me how to do such a program using command line arguments I would really appreciate it. Thank You. Here is my program so far.

}[CODE]findAveCodeCode:#include <iostream> #include <stdlib.h> using namespace std; double findAve(int lower, int upper, int array[]) { double sum = 0; int numpoints = array[0]; for (int i = lower; i <=upper; i++) { sum = sum + array[i]; return sum/lower+upper; } } int main(int argc, char *argv[]) { int x, y, arr[50]; cout << " enter a lower value: "; cin >> x; cout << " enter an upper value: "; cin >> y; cout << findAve(x, y, arr) << endl; system("PAUSE"); return 0;