array

28 1 [Error] expected unqualified-id before '{' token
May I ask what is wrong? if I remove the ; more errors happen, but if (;) stayed, that error above shows. thank you!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  #include<iostream>
#include<iomanip>
using namespace std;

const int NUMBER_OF_BSIT1B_STUDENTS=5, NUMBER_OF_ACTIVITIES=4;

void compute_st_ave(const int grade [][NUMBER_OF_ACTIVITIES], double st_ave[]);
void compute_activities_ave(const int grade [][NUMBER_OF_ACTIVITIES], double activities_ave[]);
void display(const int grade[][NUMBER_OF_ACTIVITIES], const double activities_ave[]);

int main()
{
	int grade[NUMBER_OF_BSIT1B_STUDENTS][NUMBER_OF_ACTIVITIES];
	double st_ave[NUMBER_OF_BSIT1B_STUDENTS];
	double activities_ave[NUMBER_OF_ACTIVITIES];
	
	grade[0][0]=10;   grade[0][1]=10;   grade[0][2]=10;
	grade[1][0]=2;    grade[1][1]=0;    grade[1][2]=1;
	grade[2][0]=8;    grade[2][1]=6;    grade[2][2]=9;
	grade[3][0]=8;    grade[3][1]=4;    grade[3][2]=10;
	
	compute_st_ave(grade, st_ave);
	compute_activities_ave(grade, activities_ave);
	display(grade, activities_ave);
}

void compute_st_ave(const int grade[][NUMBER_OF_ACTIVITIES], double st_ave[]);
{
	for(int st_num=1; st_num<=NUMBER_OF_BSIT1B_STUDENTS; st_num++)
	{
		double sum=0;
		for(int activities_num=1; activities<=NUMBER_OF_ACTIVITIES; activities_num++)
		sum=sum+grade[st_num-1][activities_num-1];
		st_ave[st_num-1]=sum/NUMBER_OF_ACTIVITIES;
	}
}

void display(const int grade[][NUMBER_OF_ACTIVITIES], 
const double st_ave[], const double activities_ave[]);
{
	using namespace std;
	cout.setf(ios::fixed);
	cout.setf(ios::showpoint);
	cout.precision(1);
	
	cout<<setw(10)<<"STUDENT"
	    <<setw(5)<<"AVERAGE"
	    <<setw(15)<<"ACTIVITIES"<<endl;
	    
	for (int st_num=1; st_num<=NUMBER_OF_BSIT1B_STUDENTS; st_num++)
	{
		cout<<setw(10)<<st_num
		    <<setw(5)<<st_ave[st_num-1]<<" ";
	for (int activities_number=1; activities_number<=NUMBER_OF_ACTIVITIES; activities_number++)
	cout<<setw(5)<<grade[st_num-1][activities_number-1];
	cout<<endl;
	}
	
	cout<<"ACTIVITIES AVERAGE= ";
	for (int activities_number=1; activities_number<=NUMBER_OF_ACTIVITIES; activities_number++)
	cout<<setw(5)<<activities_number[activities_number-1];
	cout<<endl;
}
Line 27 should not have a semicolon.

Line 32 should be:
 
for (int activities_num = 1; activities_num <= NUMBER_OF_ACTIVITIES; activities_num++)


Line 39 should not have a semicolon

Line 61: You can't index your loop counter.
 
cout << setw(5) << activities_number[activities_number - 1];




Registered users can post here. Sign in or register to post.