I'm actually just playing around with this program. It asks how many students are in the class, it asks for the student ID, then for each student it asks for three grades. It outputs each student's three grades, average, and letter grade.

What I would like it to do is JUST tell whether the student passed or failed, OR just tell the letter grade. How would I go about doing this?

I don't need it to ask for the number of students, I just need it to work with one. Therefore it doesn't need to ask for a student ID.

I just need it simplified

Thanks.

Code:
```#include <stdio.h>

#define 	MAXSTUDENTS 	25

int	totalStudents;

struct studentrec {
int q1,
q2,
q3,
id,
avg;
}	 studentRecordsStructure[MAXSTUDENTS];

int checkID( int temp ) {

int myBool, y;
myBool = 1;

printf("                verifying unique ID....");
for (y = 0; y < totalStudents; y++){

if (temp == studentRecordsStructure[y].id) {
printf("\nthe ID \"%d\" is taken. try another. >", temp);
return myBool;
}
}

myBool = 0;
printf("  ID %d accepted.\n", temp);
return myBool;
}

void get_a_rec( struct studentrec *student ) {

int temp, boolean;
boolean = 1;

printf("\n please enter student ID : ");

do {
scanf ("%d", &student->id);
boolean = checkID(student->id);
} while (boolean == 1);

printf(" :: quiz 1 :: ");
scanf ("%d", &student->q1);
printf(" :: quiz 2 :: ");
scanf ("%d", &student->q2);
printf(" :: quiz 3 :: ");
scanf ("%d", &student->q3);
}

int average ( struct studentrec student ) {
int sum = 0;
sum = student.q1 + student.q2 + student.q3;
return sum / 3;
}

char letter_grade ( int score ) {
if	 	(score	>=	90) return 'A';
else if (score	>=	80) return 'B';
else if (score	>=	70) return 'C';
else if (score	>=	60) return 'D';
else					return 'F';
}

void getStudentRecords() {

int i, cont;

cont = 0;
totalStudents = 0;

do{
printf("\n\nHow many students are in your class? (MAX = 25) > ");
scanf ("%d", &totalStudents);
if ( (totalStudents <= MAXSTUDENTS) && ( totalStudents > 0 ) ) { cont = 1; }
} while (cont == 0);

for (i = 0; i < totalStudents; i++) {

struct studentrec st1;
get_a_rec ( &st1 );
st1.avg = average( st1 );
studentRecordsStructure[i]= st1;
}
}

void sortStudentRecords() {

int u, v;

struct studentrec sortTemp;

for ( u = 0; u < (totalStudents - 1); u++) {
for ( v = 0; v < (totalStudents - (u + 1)); v++) {
if ( studentRecordsStructure[v].avg < studentRecordsStructure[v+1].avg ) {
sortTemp = studentRecordsStructure[v];
studentRecordsStructure[v] = studentRecordsStructure[v+1];
studentRecordsStructure[v+1] = sortTemp;
}
}
}
}

void printStudentRecords() {

int j;
printf(" \n\n");
printf("  ID____Q1____Q2____Q3____AVG___LTR_\n");
for (j = 0; j < totalStudents; j++) {
printf(" %3d ..%3d . %3d . %3d .. %3d . %3c \n",
studentRecordsStructure[j].id,
studentRecordsStructure[j].q1,
studentRecordsStructure[j].q2,
studentRecordsStructure[j].q3,
studentRecordsStructure[j].avg,
} printf("\nciao.\n\n");
}

main() {

getStudentRecords();
sortStudentRecords();
printStudentRecords();

}```

2. steps

1. get input the from user to send scores to some variables (or initialize some variables to a certain score)
2. do calculations on those variables to get the overall grade
3. send the overall grade variable to a switch statement or use multiple if-else (like the letter_grade function in your post) that outputs if student pass/fails

I'm just going to write out a very simple way to do it. This is just the main function.

Code:
```int main(){
int score1, score2, score3, total;  // could use arrays but this is just for simplicity

cout<<"enter 3 scores";
cin>>score1>>score2>>score3;
total = score1+score2+score3; // this is just adding. rewrite to perform your own calculations.

switch(total)
{

case 150: cout<<"bad for 3 tests.";
break;

case 300: cout<<"you're a genius. perfect scores!";
break;

default: cout<<"sorry. can't analyze the total";
}//end of switch statement

return 0;
}//end of main function```

3. This is C, not C++. Also get rid of that global variable and make main return int.