What is the source-code to find the sum and avg of given numbers using arrays?

i want a program in c++ to find the sum and average of given numbers using ARRAYS.

Please kindly help me by writing the source code for the above quesion!

Ashley
Well do you have anything so far you can show us - code wise?
int sum;
iterate through the array{
add every element to sum
}
average = sum / number_of_elements
#include <iostream.h>
#define SIZE 10

int sum(int num[] , int size);
int average(int result , int size);
void main()
{
int numbers[SIZE ];
int result;
int averages;


for(int i =0 ; i < SIZE ; i++)
{
numbers[i] = rand();

}
result = sum(numbers , SIZE );
averages = average(result , SIZE );
cout << " Sum = "<<result <<endl;
cout << " Average = "<<averages<<endl;


}

int sum(int num[] , int size)
{
int result = 0;
for(int i = 0; i < size; i++)
{
result = result + num[i];
}
return result ;
}
int average(int result , int size)
{
int average = result / size;
return average;
}
-) it's <iostream>, not <iostream.h>

-) it's int main() not void main()

-) blech @ #define for constants

-) don't post direct solutions for problems (at least not for people learning the language). Teach someone to fish rather than giving them a fish, etc.

-) ashleykathy needs to stop posting every homework assignment she gets on this forum. This isn't a homework service.
Topic archived. No new replies allowed.