cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/04/13/09:46:40

Message-ID: <37134A93.C949EC16@pallen.dabsol.co.uk>
Date: Tue, 13 Apr 1999 14:45:55 +0100
From: Peter Allen <P DOT Allen AT pallen DOT dabsol DOT co DOT uk>
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>
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 <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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019