For the part of the code that I am on my current struggle is find out how to take my original array and creating a new array of deviation values from the average of the numbers in the first array. I'm stuck on this question and any help given would be greatly appreciated. I tried a couple different things but they didn't work so my code looks a little obscure right now.
The total question is:
Write a program to input or initialize the following integer numbers into an array called grades: 89,95,72,83,99,55,86,75,92,73,97,75, 82,73,88. Calculate the average of the numbers and use the average to determine the deviation of each value from the average.
[i]Store each deviation in an array named deviation.[/i] Each deviation is obtained as the element value less the average of all the data. Have your program display each deviation alongside its corresponding element from the grades array.
Calculate the variance of the data. The variance is obtained by squaring each
individual deviation and dividing the sum of the squared deviations by the number of
deviations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
using namespace std;
int main()
{
const int arraysize= 15;
double average, sum=0, dev=0;
int deviation[arraysize];
int grades[arraysize]= {89, 95, 72, 83, 99, 55,86,75,92, 73, 97,75, 82, 73, 88};
for (int i=0; i<15; i++)
sum = sum+ grades[i];
average= sum/arraysize;
for (int i=0; i<15; i++)
{deviation[i]
|