im a student, and im currently working on a program to calculate GPA, but it seems doesn't run...
can anyone help me?
Code:
#include <stdio.h>
#include <string.h>
#define CLASS_SIZE 3
void main()
{
int mark[CLASS_SIZE][2];
float gp[CLASS_SIZE][2], gpa[CLASS_SIZE];
char grade[CLASS_SIZE][2];
int student, unit;
for (student=1;student<=CLASS_SIZE;++student){
for (unit=1;unit<=2;++unit){
printf("Please enter the mark for subject no.%d for student no.%d:", unit, student);
scanf("%d", &mark[student][unit]);
if (mark[student][unit]<=100||mark[student][unit]>=80)
gp[student][unit] = 4.00;
else if (mark[student][unit]<=79||mark[student][unit]>=75)
gp[student][unit] = 3.75;
else if (mark[student][unit]<=74||mark[student][unit]>=70)
gp[student][unit] = 3.50;
else if (mark[student][unit]<=69||mark[student][unit]>=65)
gp[student][unit] = 3.00;
else if (mark[student][unit]<=64||mark[student][unit]>=60)
gp[student][unit] = 2.75;
else if (mark[student][unit]<=59||mark[student][unit]>=55)
gp[student][unit] = 2.50;
else if (mark[student][unit]<=54||mark[student][unit]>=50)
gp[student][unit] = 2.00;
else if (mark[student][unit]<=49||mark[student][unit]>=45)
gp[student][unit] = 1.75;
else if (mark[student][unit]<=44||mark[student][unit]>=40)
gp[student][unit] = 1.00;
else if (mark[student][unit]<=39||mark[student][unit]>=0)
gp[student][unit] = 0.00;
else
gp[student][unit] = 0.00;
if (gp[student][unit] == 4.00)
strcpy(grade[student][unit],'A');
else if (gp[student][unit] == 3.75)
strcpy(grade[student][unit],'A-');
else if (gp[student][unit] == 3.50)
strcpy(grade[student][unit], 'B+');
else if (gp[student][unit] == 3.00)
strcpy(grade[student][unit], 'B');
else if (gp[student][unit] == 2.75)
strcpy(grade[student][unit], 'B-');
else if (gp[student][unit] == 2.50)
strcpy(grade[student][unit], 'C+');
else if (gp[student][unit] == 2.00)
strcpy(grade[student][unit], 'C');
else if (gp[student][unit] == 1.75)
strcpy(grade[student][unit], 'C-');
else if (gp[student][unit] == 1.00)
strcpy(grade[student][unit], 'D');
else
strcpy(grade[student][unit], 'F');
}
}
for (student=1;student<=CLASS_SIZE;++student)
printf("%s %s %.2d %.2d\n", grade[student][1], grade[student][2], gp[student][1], gp[student][2]);
}