Help!

For the sake of it, I am just going to post my whole program so far. My question is I keep getting an error that says

error C2143: syntax error : missing ';' before ')'

It is the last function in my code and goes to this line ( for( int i = 1;) )


What am I possibly doing wrong?!




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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;

const int MAX_ARRAY = 500;

void getData(ifstream& inFile, int inValues[], int& size);
double getAverage(int inValues[], int dataSize); 
void MaxMin(int theData[], int dataSize, int&Max, int&Min);
double StandardDev(int inValues[], int numElems, double Ave);
void QSummery(int inValues[]);


int main()
{
    ifstream fileIn;                
    
    int theData[MAX_ARRAY];     // Array for data storage
    int numElems;               // Actual number of values in array 
                                // (1 more than largest index)
	int Max, Min;				// decleration for maximum and minimum values
	double Ave;
	double SDev;

    fileIn.open("avedata.txt"); // Open file
    
    if (fileIn.fail() )         // Test for file existence
    {
      cout <<  "Problem opening file";
      exit(-1);
    }
    
    // Read file and count values in array
    getData(fileIn,theData,numElems);
    
   // Determine and write average; test first for non-empty data file   
    if (numElems > 0)
	{
	   Ave = getAverage(theData,numElems);
       cout << "Average Test Score: " << Ave << endl << endl;
	}
     else
       cout << "ERROR:  No data processed" << endl << endl;

 MaxMin(theData, numElems, Max, Min);

	//return max and min value
	if (numElems > 0)
		cout << "Max: " << Max << " Min: " << Min << endl << endl;
	else 
		cout << "ERROR: No data processed" << endl << endl;

SDev = StandardDev(theData, numElems, Ave);

	//returns the standard deviation
	cout << "The standard deviation for the data set is: " << SDev << endl;

	QSummery(theData);

    // Close file
    fileIn.close();    

	system("pause");
   
    return 0;                
} 

// This function reads integers from a file and stores the values in
// an array.  It returns the loaded array and the number of elements 
// in the array
void getData(ifstream& inFile, int inValues[], int& numVals)
{
    int i = 0;
    inFile >> inValues[i];                
    while (!inFile.eof() && i < MAX_ARRAY)    // Test for end of file and array    
    {
       i++;        
       inFile >> inValues[i];
    }            
    numVals = i;
}

// This function receives an array of integers, calculates the average
// of the array values, and returns it.
double getAverage(int inValues[], int dataSize)
{
    double sum = 0.0;
    
    for (int i = 0; i < dataSize; i++)
       sum = sum + inValues[i];    
       
    return sum / dataSize; 
}

//This function will calculate and return the maximum and minimum value
void MaxMin(int theData[], int dataSize, int&Max, int&Min)
{
     Max = theData[0];       // start with max = first element

     for(int i = 1; i<dataSize; i++)
     {
          if(theData[i] > Max)
                Max = theData[i];
     }
	  Min = theData[0];       // start with min = first element

     for(int i = 1; i<dataSize; i++)
     {
          if(theData[i] < Min)
                Min = theData[i];
     }
}
 // This function will calculate the standard deviation  of the numbers in the data set
 double StandardDev(int inValues[], int numElems, double Ave)
 {
	 double StandardDev;
	 double sum = 0;
	 double temp;
	 for (int i = 0; i < numElems-1; i++)
	 {
		 temp = inValues[i] - Ave;
		 sum = sum + pow(temp, 2);
	 }
	 StandardDev = sqrt(sum/ (numElems-1));

	 return StandardDev;
 
 }

void QSummery(int inValues[])
 {
	 double quartile4, quartile3, quartile2, quartile1;
	 for( int i = 1;)
	 if (inValues[i] > 74)
		 quartile4++;
	 else if (inValues[i] > 49)
		 quartile3++;
	 else if (inValues[i] > 24)
		 quartile2++;
	 else 
		 quartile1++;

	 cout << "The Quartile 4, scores between 75 - 100 are as follows: " << quartile4 << endl;
	 cout << "The Quartile 3, scores between 50 - 74 are as follows: " << quartile3 << endl;
	 cout << "The Quartile 2, scores between 25 - 49 are as follows: " << quartile2 << endl;
	 cout << "The final Quartile, 1, scores between 0 - 24 are as follows: " << quartile1 << endl;
 }
for( int i = 1;)

it is obvious that the statement has incorrect syntax.
Topic archived. No new replies allowed.