Mail Archives: djgpp/1999/04/13/01:40:49
Message-ID: | <3711F7C5.29C@pacbell.net>
|
From: | thethoms <thethoms AT pacbell DOT net>
|
X-Mailer: | Mozilla 2.02 (OS/2; I)
|
MIME-Version: | 1.0
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Help! One dimensional arrays aren't working!
|
Lines: | 92
|
Date: | Mon, 12 Apr 1999 09:40:21 -0400
|
NNTP-Posting-Host: | 207.215.220.220
|
X-Complaints-To: | abuse AT pacbell DOT net
|
X-Trace: | typhoon-sf.pbi.net 923979980 207.215.220.220 (Mon, 12 Apr 1999 22:06:20 PDT)
|
NNTP-Posting-Date: | Mon, 12 Apr 1999 22:06:20 PDT
|
Organization: | SBC Internet Services
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Hi!
Here is my code: (A description of the problem follows it).
//Travis Thoms //
//03/30/99 //
#include <iostream.h>
#include <fstream.h>
#include <math.h>
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= "<<Mean<<endl;
cout<<"StdDev= "<<StdDev<<endl;
cout<<"Percent of scores"<<endl<<endl;
cout<<"Under 10= "<<lessTen*100/counter<<"%"<<endl;
cout<<"10-19= "<<lessTwenty*100/counter<<"%"<<endl;
cout<<"20-29= "<<lessThirty*100/counter<<"%"<<endl;
cout<<"30-39= "<<lessForty*100/counter<<"%"<<endl;
cout<<"40-49= "<<lessFifty<<"%"<<endl;
cout<<"50-59= "<<lessSixty*100/counter<<"%"<<endl;
cout<<"60-69= "<<lessSeventy*100/counter<<"%"<<endl;
cout<<"70-79= "<<lessEighty*100/counter<<"%"<<endl;
cout<<"80-89= "<<lessNinety*100/counter<<"%"<<endl;
cout<<"90-100= "<<lessHundred*100/counter<<"%"<<endl;
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
- Raw text -