R
Richard
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_scores, number_of_student;
cout<<"How many student do you want to average test scores? : ";
cin >>student_record;
student_info* student = new student[student_record];
cout<<"How many test scores do you want to calculate average for this
student? : ";
cin >>number_test_scores;
student.test_scores = new student.test_scores[number_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_scores, number_of_student;
cout<<"How many student do you want to average test scores? : ";
cin >>student_record;
student_info* student = new student[student_record];
cout<<"How many test scores do you want to calculate average for this
student? : ";
cin >>number_test_scores;
student.test_scores = new student.test_scores[number_test_scores];
}