Mail Archives: djgpp/1999/04/13/06:53:16
From: | Martin Ambuhl <mambuhl AT earthlink DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Help! One dimensional arrays aren't working!
|
Date: | Tue, 13 Apr 1999 03:45:35 -0400
|
References: | <3711F7C5 DOT 29C AT pacbell DOT net>
|
X-Posted-Path-Was: | not-for-mail
|
X-Accept-Language: | en
|
X-ELN-Date: | 13 Apr 1999 07:44:41 GMT
|
X-ELN-Insert-Date: | Tue Apr 13 00:45:05 1999
|
Organization: | Nocturnal Aviation
|
Lines: | 125
|
Mime-Version: | 1.0
|
NNTP-Posting-Host: | 1cust48.tnt11.nyc3.da.uu.net
|
Message-ID: | <3712F61F.78D48DEE@earthlink.net>
|
X-Mailer: | Mozilla 4.51 [en] (Win95; I)
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
thethoms wrote:
>
> Hi!
>
> Here is my code: (A description of the problem follows it).
[...]
> 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?
I can't believe a C++ instructor doesn't know page 1 C++ stuff. Try this:
// Travis Thoms
// 03/30/99
#include <iostream>
#include <fstream>
#include <cmath>
ifstream inData;
int LegalNameInsteadOfReservedWord_class[100] =
{-1};
#define classnumber classNumber // to take care of undefined identifier
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 >> LegalNameInsteadOfReservedWord_class[classnumber];
while (LegalNameInsteadOfReservedWord_class[classnumber] != -1) {
classNumber++;
Sum = Sum + LegalNameInsteadOfReservedWord_class[classnumber];
if (LegalNameInsteadOfReservedWord_class[classnumber] < 10)
lessTen++;
if ((LegalNameInsteadOfReservedWord_class[classnumber] >= 10) &&
(LegalNameInsteadOfReservedWord_class[classnumber] <=
19))
lessTwenty++;
if ((LegalNameInsteadOfReservedWord_class[classnumber] >= 20) &&
(LegalNameInsteadOfReservedWord_class[classnumber] <=
29))
lessThirty++;
if ((LegalNameInsteadOfReservedWord_class[classnumber] >= 30) &&
(LegalNameInsteadOfReservedWord_class[classnumber] <=
39))
lessForty++;
if ((LegalNameInsteadOfReservedWord_class[classnumber] >= 40) &&
(LegalNameInsteadOfReservedWord_class[classnumber] <=
49))
lessFifty++;
if ((LegalNameInsteadOfReservedWord_class[classnumber] >= 50) &&
(LegalNameInsteadOfReservedWord_class[classnumber] <=
59))
lessSixty++;
if ((LegalNameInsteadOfReservedWord_class[classnumber] >= 60) &&
(LegalNameInsteadOfReservedWord_class[classnumber] <=
69))
lessSeventy++;
if ((LegalNameInsteadOfReservedWord_class[classnumber] >= 70) &&
(LegalNameInsteadOfReservedWord_class[classnumber] <=
79))
lessEighty++;
if ((LegalNameInsteadOfReservedWord_class[classnumber] >= 80) &&
(LegalNameInsteadOfReservedWord_class[classnumber] <=
89))
lessNinety++;
if ((LegalNameInsteadOfReservedWord_class[classnumber] >= 90) &&
(LegalNameInsteadOfReservedWord_class[classnumber] <=
100))
lessHundred++;
inData >> LegalNameInsteadOfReservedWord_class[classnumber];
}
Mean = float (Sum / classnumber);
inData >> LegalNameInsteadOfReservedWord_class[counter];
while (LegalNameInsteadOfReservedWord_class[counter] != -1)
Sample =
pow((LegalNameInsteadOfReservedWord_class[counter] -
Mean), 2);
// mha - added ';' to the above
StdDev = sqrt(Sample / (classnumber - 1));
// mha - added ';' to the above
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;
}
--
Martin Ambuhl (mambuhl AT earthlink DOT net)
Note: mambuhl AT tiac DOT net will soon be inactive
- Raw text -