Please help can you help me debug my code i cant display the result and the computation for sum is error...
help me please :sad:
#include <stdio.h>
int i,counter;
float sum;
struct cgrade
{
char course[50];
float credit[50];
float grade[50];
};
struct cgrade GPA[50];
main(){
printf("Enter number of courses to input:");
scanf("%d",&counter);
sum=0;
for(i=0;i<counter;i++){
printf("Enter course:");
fflush(stdin);
gets(GPA[i].course);
printf("Enter credit:");
scanf("%f",&GPA[i].credit);
printf("Enter grade:");
scanf("%f",&GPA[i].grade);
sum=sum+GPA[i].credit;
}
printf("Sum: %f",sum);
for(i=0;i<counter;i++){
printf("Course %s\n",GPA[i].course);
printf("Credit %f\n",GPA[i].credit);
printf("Grade %f\n",GPA[i].grade);
}
getch();
}