I need to know if this program that I have made is correct according to the instructions given to me.
I want to know if I did something incorrectly or misunderstood the instructions.
Write a complete C++ program that will let a user input 8 integer values into an array. After entering the values display the following statistics: The third element in the array The average of all the numbers The difference between the maximum and the minimum numbers in the array.
First of all, I should note that I'm not getting the difference between the max and min numbers in the array. Why?
using namespace std;
void readem(int * & number, int &quant)
quant = 8;
number = new int[quant];
for(int i=0; i<quant; i++)
cout << "\nEnter the value for number " << i+1 << "? ";
cin >> number[i];
int sum(const int array, int num)
for(int i=0; i < num; i++)
total += array[i];
void sortArray(int array, int elems)
int temp, diff;
swap = false;
for (int count = 0; count < (elems - 1); count++)
if (array[count] > array[count +1])
temp = array [count];
array[count] = array[count+1];
array[count +1] = temp;
swap = true;
} while (swap);
cout << "\nThe third element is " << array;
diff = (array - array);
cout << "\nThe difference between the max and min numbers is: "<< diff;
int * number;
int num = 0;
total = sum(number, num);
cout << "\nAverage = " << float(total)/num << endl;