65 875
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #24389 in C++ for Nourah

Question #24389
Write a function called Average that takes in an array of ints and calculates and returns the average of those numbers.
Expert's answer
#include <iostream>
using namespace std;

#include <conio.h>

double average(int* array, int size)
{
int val = 0;
for(i = 0;i < size; i++ )
{
val = val + *array[i];
}
double av = val/size;
return size;
}

int main()
{
int size;
cout << "Input size of array: ";
cin >> size;
int* array = new int[size];
cout << "Input the integer numbers";
for(int i = 0; i < size;i++)
{
& cout << "array["<<i+1<<"]: ";
& cin >> *array[i];
}
cout << endl<< "The average value is: "<<average(array,size);

getch();& &
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions