Too many errors??

Hi, I'm new to this forum!I recently wrote a program in C++ , but I get 19 errors!! I would really apreciate it if someone helped me find the errors of my program.

Here is the code :



#include <iostream>
using std::cout;
using std::endl;
using std::fixed;
using std::showpoint;

#include <iomanip>
using std::setw;
using std::setprecision;

void mean( const int [], int );
void median( int[], int );
void mode( int[], int[], int );
void PrintArray( const int [], int );
void BubbleSort ( int[], int );


int main()
{

const int responseSize = 100;

int frequency[ 10 ] = { 0 };

int response[ responseSize ] =
{ 8,9,4,5,2,6,1,7,8,9
6,2,3,7,4,8,9,5,1,2
7,1,4,5,9,8,7,4,2,5
1,2,3,6,5,4,7,8,5,6
8,5,2,6,9,7,1,2,6,7
8,1,8,3,8,4,1,7,8,9
6,2,3,7,4,8,9,5,1,2
9,1,4,6,3,8,7,4,2,5
6,2,3,4,5,4,2,3,8,5
7,5,2,7,9,7,3,2,9,4 };


mean( response, responseSize );
median( response, responseSize );
mode( frequency, response, responseSize);

return 0;


}


void mean( const int answer[], int arraySize )
{
int total = 0;

cout << "*****\nMean\n*****\n";
for ( int i = 0; i < arraySize; i++ )
total += answer[ i ];

cout << fixed << setprecision( 4 );

cout << "The mean is the average value of the data\n"
<< "items.The mean is equal to the total of all\n"
<< "the data items ( " << arraySize " ). The mean value\n"
<< "for this run is : " << total << "/ " << arraySize << "="
<< static_cast< double >( total ) / arraySize << "\n\n";

}


void BubbleSort( int a[], int size )
{
int hold;

for ( int pass = 0; pass < size; pass++)


for ( int j = 0; j < size - 1; j++ )


if ( a[ j ] > a[ j + 1 ] ){

hold = a[ j ];
a[ j ] = a[ j + 1 ];
a[ j + 1 ] = hold;


}

}


void PrintArray( const int a[], int size )
{
for ( int i = 0; i < size; i++ ){


if ( i % 20 == 0 )
cout << endl;


cout << setw( 3 ) << a[ i ];
}

}




void median( int answer[], int size )
{
cout << "*****\nMedian\n*****\n";
cout << "The unsorted array of responses is :\n";

PrintArray( answer, size );


BubbleSort( answer, size );

cout << "The sorted array is :\n";
PrintArray( answer, size );


cout << "The median is element " << size / 2
<< "\nof the sorted" << size << "element array."
<< "\nFor this run , the median is " << answer[ size / 2 ] <<"\n\n";


}

void mode( int freq[], int answer[], int size )
{

int largest = 0;
int modeSize = 0;

cout << "*****\nMode\n*****\n";

for ( int i = 1; i <= 9; i++ )
freq[ i ] = 0;

for ( int j = 0; j < size; j++ )
++freq[ answer[ j ] ];


cout << "Response" << setw( 10 ) << "Frequency" << setw( 10 ) << "Histogram" << endl;

for ( int rating = 1; rating <= 9; rating++ ){
cout << rating << setw( 10 ) << freq[ rating ] << " ";

if ( freq[ rating ] > largest ){

largest = freq[ rating ];
modeSize = rating;

}


for ( int k = 0; k < freq[ rating ]; k++ )
cout << "*";
}


cout << "\nThe mode is the most frequent value."
<< "\nFor this run , the mode is " << modeSize
<< "\nwhich occured " << largest << " times. " << endl;



}

Do not fear. Most of the time later errors stems from first (because compiler already understood your code wrong). In your case there are only 2 actual errors, (well, first one has 8 instances).

First one:
1
2
3
4
5
6
7
8
9
10
11
12
    int response[ responseSize ] = {
        8,9,4,5,2,6,1,7,8,9
        6,2,3,7,4,8,9,5,1,2
        7,1,4,5,9,8,7,4,2,5
        1,2,3,6,5,4,7,8,5,6
        8,5,2,6,9,7,1,2,6,7
        8,1,8,3,8,4,1,7,8,9
        6,2,3,7,4,8,9,5,1,2
        9,1,4,6,3,8,7,4,2,5
        6,2,3,4,5,4,2,3,8,5
        7,5,2,7,9,7,3,2,9,4
    };
Take a look on accentuated parts. Remember that whitespace characters (including newline) are optional in most cases in C++. So that part looks like:
/*...*/,8,9 6,2,/*...*/. See the problem?
Same thing in each line of your array declaration.

Second error is here: << "the data items ( " << arraySize " ). The mean value\n". You forgot something.
Oh alright! Found the first one , thanks! The other one though ( << "the data items ( " << arraySize " ). The mean value\n" ) is a little tricky.... It sais I missed ';' before 'string'.....
Nevermind , solved it!! Thanks!
Topic archived. No new replies allowed.