Array Help

Hello All,

I am trying to make an array and this is what I have so far:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <fstream>
#include <string>

using namespace std;
 
//Shawn Van Horn, Chapter 7, 3/15/13

int main()
{
 string str[x][n];
 ifstream myfile("randomData.txt");
 inFile.precision(2);
 inFile.setf(ios::fixed, ios::showpoint);

double mean(double x[], int n);
 double stddev(double x[], int n);

inFile
while(!inFile.eof())
{
for (int x = 0; x < 6; x++)
{
for (int n = 0; n < 4; nt++)
{
infile >> randomData[x][n]
}
}
}
inFile.close();
 
}

//System Pause

 system("PAUSE");

 return 0;
}


This is assignment:

Choose one of the options listed below. The data file is attached to the assignment link. Do not use vectors or strings for options (1), (2) or (4) – I want you to use arrays.

Option (1) Write a program that reads a list of numbers from a data file into an array. The number of values in the file is unspecified but you can assume that it is no more than 100 data values. The program will then display the values and the number of numbers in the data file. It will also display the average and the standard deviation of the two data values. The calculations for the average and standard deviation should each be done in a function. Use the following prototypes for your function:

double mean(double x[], int n);

double stddev(double x[], int n);

x is the array and n is the number of data values in the array. The first function returns the mean as type double and the second returns the standard deviation at type double.


Can you please help of what I am messing up on. I have used these forums to try and figure this out, but still am having trouble.

Random Code Looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
77.39
89.54
82.51
88.48
92.09
81.74
99.40
95.44
109.95
88.63
111.84
90.28
110.37
104.09
97.64
101.66
98.35
98.71
95.17
96.11
91.10
94.16

Topic archived. No new replies allowed.