Define a record structure to hold a set of test scores,
number of tests, and the average score. The number of
records are to be determined at runtime. Also the
number of tests for each record is to be determined at
runtime. Calculate the average test score for the set
the set of test scores in each record. Display records.
Demonstrate with a least five records. I program I wrote have three errors
and I don't really know what they are. Can anyone help?
The errors are:
Error 1 error C2061: syntax error : identifier
Error 2 error C2228: left of '.test_scores' must have class/struct/union
Error 3 error C2061: syntax error : identifier 'student' 9
Here are the code:
# include <iostream>
# include <string>
using namespace std;
// structure declaration
struct student_info
{
char name[20];
float* test_scores; // memory will be allocated dynamically
float average_ts;
};
// function prototypes passing structure into function
void main()
{
int student_record= 0, number_test_sco res, number_of_stude nt;
cout<<"How many student do you want to average test scores? : ";
cin >>student_recor d;
student_info* student = new student[student_record];
cout<<"How many test scores do you want to calculate average for this
student? : ";
cin >>number_test_s cores;
student.test_sc ores = new student.test_sc ores[number_test_sco res];
}
number of tests, and the average score. The number of
records are to be determined at runtime. Also the
number of tests for each record is to be determined at
runtime. Calculate the average test score for the set
the set of test scores in each record. Display records.
Demonstrate with a least five records. I program I wrote have three errors
and I don't really know what they are. Can anyone help?
The errors are:
Error 1 error C2061: syntax error : identifier
Error 2 error C2228: left of '.test_scores' must have class/struct/union
Error 3 error C2061: syntax error : identifier 'student' 9
Here are the code:
# include <iostream>
# include <string>
using namespace std;
// structure declaration
struct student_info
{
char name[20];
float* test_scores; // memory will be allocated dynamically
float average_ts;
};
// function prototypes passing structure into function
void main()
{
int student_record= 0, number_test_sco res, number_of_stude nt;
cout<<"How many student do you want to average test scores? : ";
cin >>student_recor d;
student_info* student = new student[student_record];
cout<<"How many test scores do you want to calculate average for this
student? : ";
cin >>number_test_s cores;
student.test_sc ores = new student.test_sc ores[number_test_sco res];
}
Comment