C
C++Geek
I need the following code to take the actual number of students and
quizzes to be entered via the keyboard but to be less than the const
students (stu_num and quiz_num). the error messages I am getting are
as follows:
error C2065: 'size' : undeclared identifier
error C2065: 'grades' : undeclared identifier
error C2143: syntax error : missing ';' before '}'
Any help would be greatly appreciated
#include <iostream>
#include <iomanip>
const int stu_num = 10, quiz_num = 8;
void func_st_ave(const int grade[][quiz_num], double st_ave[]);
void func_quiz_ave(const int grade[][quiz_num], double quiz_ave[]);
void display(const int grade[][quiz_num],
const double st_ave[], const double
quiz_ave[]);
int main( )
nts and Setti
{
using namespace std;
int grade[stu_num][quiz_num];
double st_ave[stu_num];
double quiz_ave[quiz_num];
cout<<"enter number of students
"<<endl;
cin>>size;
cout<<"enter number of grades"<<endl;
cin>>grades;
for(int size=0; size< stu_num; size++)
{
cout<<"enter grades for students"<<size+1;
for(int grades=0; grades <quiz_num; grades++)
}
func_st_ave(grade, st_ave);
func_quiz_ave(grade, quiz_ave);
display(grade, st_ave, quiz_ave);
return 0;
}
void func_st_ave(const int grade[][quiz_num], double st_ave[])
{
for (int st = 1; st <= stu_num; st++)
{
double sum = 0;
for (int qu = 1; qu <= quiz_num; qu++)
sum = sum + grade[st-1][qu-1];
st_ave[st-1] = sum/quiz_num;
}
}
void func_quiz_ave(const int grade[][quiz_num], double quiz_ave[])
{
for (int qu= 1; qu <= quiz_num; qu++)
{
double sum = 0;
for (int st = 1; st <= stu_num; st++)
sum = sum + grade[st-1][qu-1];
quiz_ave[qu-1] = sum/stu_num;
}
}
//Uses iostream and iomanip:
void display(const int grade[][quiz_num],
const double st_ave[], const double
quiz_ave[])
{
using namespace std;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(1);
cout << setw(10) << "Student"
<< setw(5) << "Ave"
<< setw(15) << "Quizzes\n";
for (int st = 1; st <= stu_num; st++)
{
cout << setw(10) << st
<< setw(5) << st_ave[st-1] << " ";
for (int qu = 1; qu <= quiz_num; qu++)
cout << setw(5) << grade[st-1][qu-1];
cout << endl;
}
cout << "Quiz averages = ";
for (int qu = 1; qu <= quiz_num; qu++)
cout << setw(5) << quiz_ave[qu-1];
cout << endl;
}
quizzes to be entered via the keyboard but to be less than the const
students (stu_num and quiz_num). the error messages I am getting are
as follows:
error C2065: 'size' : undeclared identifier
error C2065: 'grades' : undeclared identifier
error C2143: syntax error : missing ';' before '}'
Any help would be greatly appreciated
#include <iostream>
#include <iomanip>
const int stu_num = 10, quiz_num = 8;
void func_st_ave(const int grade[][quiz_num], double st_ave[]);
void func_quiz_ave(const int grade[][quiz_num], double quiz_ave[]);
void display(const int grade[][quiz_num],
const double st_ave[], const double
quiz_ave[]);
int main( )
nts and Setti
{
using namespace std;
int grade[stu_num][quiz_num];
double st_ave[stu_num];
double quiz_ave[quiz_num];
cout<<"enter number of students
"<<endl;
cin>>size;
cout<<"enter number of grades"<<endl;
cin>>grades;
for(int size=0; size< stu_num; size++)
{
cout<<"enter grades for students"<<size+1;
for(int grades=0; grades <quiz_num; grades++)
}
func_st_ave(grade, st_ave);
func_quiz_ave(grade, quiz_ave);
display(grade, st_ave, quiz_ave);
return 0;
}
void func_st_ave(const int grade[][quiz_num], double st_ave[])
{
for (int st = 1; st <= stu_num; st++)
{
double sum = 0;
for (int qu = 1; qu <= quiz_num; qu++)
sum = sum + grade[st-1][qu-1];
st_ave[st-1] = sum/quiz_num;
}
}
void func_quiz_ave(const int grade[][quiz_num], double quiz_ave[])
{
for (int qu= 1; qu <= quiz_num; qu++)
{
double sum = 0;
for (int st = 1; st <= stu_num; st++)
sum = sum + grade[st-1][qu-1];
quiz_ave[qu-1] = sum/stu_num;
}
}
//Uses iostream and iomanip:
void display(const int grade[][quiz_num],
const double st_ave[], const double
quiz_ave[])
{
using namespace std;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(1);
cout << setw(10) << "Student"
<< setw(5) << "Ave"
<< setw(15) << "Quizzes\n";
for (int st = 1; st <= stu_num; st++)
{
cout << setw(10) << st
<< setw(5) << st_ave[st-1] << " ";
for (int qu = 1; qu <= quiz_num; qu++)
cout << setw(5) << grade[st-1][qu-1];
cout << endl;
}
cout << "Quiz averages = ";
for (int qu = 1; qu <= quiz_num; qu++)
cout << setw(5) << quiz_ave[qu-1];
cout << endl;
}