I need to write a program using arrays and strings.Here is the question.
A class of students takes a 20 question multiple-choice exam;each question has 5 choices(a,b,c,d,e)only one of them are correct.In "tests.dat"Each record of which consists of a student id, followed by a blank, followed by students 20 responses. In "answers.dat" which consists of a single record, namely the correct answers to the exam.Then It needs to produce a grade summary report like this.If the answer is correct it should put a "*" by the correct answer
student-id number correct
1231231212312 12
1233424325435 25
.... ...
question A B C D E
1 5 1 13* 3 1
2 4 7* 5 12 7
.
.
...
this is what i got so far.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
|
#include<iostream>
#include<fstream>
#include<cstdlib>
using namespace std;
int main()
{
ifstream finans,fintests;
char key[21],id[12],responses[21],question[21];
int count[20][5];
int correct_count;
fintests.open("Tests.dat");
fintests>>id[12]>>responses[21];
finans.open("Answers.dat");
finans>>key[21];
student_count =0;
while(!fintests.eof())
{
for(int i = 0; i < student_count; i++)
{
int correct_count = 0;
for(int j = 0; j < 20; j++)
{
if (responses [i][j] == key[j])
{
correct_count++;
question[j][responses[i][j] - 'A']++;
printf("%11.11s %2d\n",id[i],correct_count);
}
}
}
cout << " student_id number_correct" << endl << endl;
cout<<id[21]<<"\t"<<correct_count<<endl;
cout << endl << endl << endl << "Number of students taking exam : " << student_count << endl;
printf("\nquestion A B C D E\n");
for(int k = 0; k < 20; k++) {
printf(" %2d ",1+k);
for(int l=0;l < 5; l++)
printf(" %2d%c ", question[k][l], (l == (key[k] - 'A') ? '*' : ' '));
printf("\n");
}
}
return 0;
}
| |
these are the errors I am getting
error C2065: 'student_count' : undeclared identifier
error C2065: 'student_count' : undeclared identifier
error C2109: subscript requires array or pointer type
error C2109: subscript requires array or pointer type
error C2065: 'student_count' : undeclared identifier
error C2109: subscript requires array or pointer type