this is the full code '''
//include all library incase needed
#include
#include
#include
#include <stdio.h>
#include
#include
using namespace std;
void fgetAnswers (char answers[], int n, FILE *inp); //functions declarations
int main()
{ FILE *inp = fopen("examdata.txt","r"); //definings files inputs
int n,i; char answers[20], ch;
fscanf(inp,"%d",&n); //scannings from files the no.of answers
fscanf(inp,"%c",&ch); for(i=0;i<n; i++)
fscanf(inp,"%c",&answers[i]); // scannings the answers.
}
// fgetAnswers(answers, n, inp); // callings the functions
//return 0;
void fgetAnswers (char answers[], int n, FILE *inp) {
FILE *outp = fopen("report.txt","w"); // defining the file output
int missed[20], i; // declaring the variable, the new array for missed question. int id, correct; char choice;
int id, correct; char choice;
fprintf(outp, "Exam Report\n\n"); // printing in the file.
fprintf(outp,"Question\t"); for(i=0;i<n; i++) {
} fprintf(outp,"%d ",i); //printing the questions numbers
fprintf(outp,"\nAnswer\t\t"); for(i=0;i<n; i++) {
fprintf(outp,"%c",answers[i]); //printings the corrects answers }
}
for(i=0;i<20;i++)
{ missed[i]=0; //initializing all missed questions to 0. }
fprintf(outp,"\n\nID\tScore (%%)\n"); //starting hte student wise report
while(fscanf(inp,"%d",&id) != EOF) //scanning the id. If end of file is not occured, the loop continues
// occured, the loop continues
{
correct=0; fprintf(outp,"%d\t", id); //printing ID
fscanf(inp,"%c",&choice); for(i=0;i<n; i++)
{ fscanf(inp,"%c",&choice); //scannings the choice.
if(choice answers[i]) //checking if == correct choice.
correct++; // if choice is correct, the student's count of correct answers is added 1.
}
else
{ missed[i]++; // if answer wrong the question's missed is added 1. }
}
fprintf(outp,"%d\n",(correct*100)/n); //printings the student's precentage correct. }
fprintf(outp,"\nQuestion\t"); //printing the final report for(i=0;i {
fprintf(outp,"%d ",i); //question numbers
}
fprintf(outp,"\nMissed by\t"); for(i=0;i
{ fprintf(outp,"%d ",missed[i]); //correspondings missed number }
fprintf(outp,"\n\n"); }
ends here '''

