Hello I have an error in the code line 62 any idea whats the error? "if(choice answers[i]) //checking if == correct choice. "

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 '''

In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.

Use the </> icon from the ‘reply menu’ to attach the copied sketch.

//include all library incase needed
#include<iostream>
#include<fstream>
#include<iomanip>
#include <stdio.h>
#include<fstream>
#include<string>


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.

}



if 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"); }


if(choice answers[i])

. . .

for(i=0;i

. . .

if else

Something is looking strange :face_with_spiral_eyes: .

where is that? line?

I stopped looking.

oh i forgot the == (condition)
thank you so much

this is the full code

//include all library incase needed
#include<iostream>
#include<fstream>
#include<iomanip>
#include <stdio.h>
#include<fstream>
#include<string>


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<n; i++)

{ fprintf(outp,"%d ",missed[i]); //correspondings missed number
}

fprintf(outp,"\n\n");
 }

Not an arduino programming question!!!!

but the compiler told you the error! you have some closing .curly brackets (}) missing from your code (not wonder really, its so messy!)

While the two threads are not technical duplicates there is benefit to having a single thread.

@secret_glow, as you struggle with syntax please post here.

I did not understand?

Don't sweat it. Just carry on.