Message-ID: <37134A93.C949EC16@pallen.dabsol.co.uk> Date: Tue, 13 Apr 1999 14:45:55 +0100 From: Peter Allen

X-Mailer: Mozilla 4.04 [en] (Win95; I) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Help! One dimensional arrays aren't working! References: <3711F7C5 DOT 29C AT pacbell DOT net> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp AT delorie DOT com I haven't got djgpp installed on this computer, and I can't start up the one on which it is installed, but looking at your code, the lines Sample=pow((class[counter]-Mean),2) and StdDev=sqrt(Sample/(classnumber-1)) both need a semi-colon after them, so they become Sample=pow((class[counter]-Mean),2); StdDev=sqrt(Sample/(classnumber-1)); There might be other things I haven't noticed, but those are the most obvious. Hope that helps, Peter Allen thethoms wrote: > > Hi! > > Here is my code: (A description of the problem follows it). > > //Travis Thoms // > //03/30/99 // > > #include > #include > #include > > ifstream inData; > int class[100]={-1}; > int classNumber=0,Sum=0,lessTen=0,lessTwenty=0, > lessThirty=0,lessForty=0,lessFifty=0,lessSixty=0,lessSeventy=0, > lessEighty=0,lessNinety=0,lessHundred=0,counter=0; > float Mean=0,Sample=0,StdDev=0; > int main() > { > //Preparation for file IO// > > inData.open("indata.txt"); > inData>>class[classnumber]; > while (class[classnumber]!=-1) > { > classNumber++; > Sum=Sum + class[classnumber]; > if(class[classnumber]<10) > lessTen++; > if((class[classnumber]>=10) && (class[classnumber]<=19)) > lessTwenty++; > if((class[classnumber]>=20) && (class[classnumber]<=29)) > lessThirty++; > if((class[classnumber]>=30) && (class[classnumber]<=39)) > lessForty++; > if((class[classnumber]>=40) && (class[classnumber]<=49)) > lessFifty++; > if((class[classnumber]>=50) && (class[classnumber]<=59)) > lessSixty++; > if((class[classnumber]>=60) && (class[classnumber]<=69)) > lessSeventy++; > if((class[classnumber]>=70) && (class[classnumber]<=79)) > lessEighty++; > if((class[classnumber]>=80) && (class[classnumber]<=89)) > lessNinety++; > if((class[classnumber]>=90) && (class[classnumber]<=100)) > lessHundred++; > > inData>>class[classnumber]; > > } > Mean=float(Sum/classnumber); > inData>>class[counter]; > while (class[counter]!=-1) > { > Sample=pow((class[counter]-Mean),2) > } > StdDev=sqrt(Sample/(classnumber-1)) > > cout<<"Mean= "< cout<<"StdDev= "< cout<<"Percent of scores"< cout<<"Under 10= "< cout<<"10-19= "< cout<<"20-29= "< cout<<"30-39= "< cout<<"40-49= "< cout<<"50-59= "< cout<<"60-69= "< cout<<"70-79= "< cout<<"80-89= "< cout<<"90-100= "< > return 0; > } > > When I compile this program, where ever there is a statement like: > > class[XXXX] > > I receive an error from the compiler: > > Parse error before XXXX > > I have had my C++ instructor look at these statements, and she can't > seem to find anything wrong. Is there some other method of doing this > in DJGPP? > > Thanks in advance! > > T. Thoms