Hello Everyone, I have been asked to write a GPA system for my college assignment and i am facing some problems. The question stated that i must use Two Dimensional Array to store the grades of all students in a class. The subjects are a fixed amount of columns which are 5. The rows however are unlimited. How do i declare/ initialize this? I am also unsure on how to store these data's.
This is all i have right now. Can anyone tell me what i am doing wrong? I am still a newbie to C.
Code:#include <stdio.h> #define MAX_COLLUMN 5 #define MAX_ROWS [] int main() { // Variable Declarations // char grade; int subjects_taken,Array[MAX_ROWS][MAX_COLLUMN],i,student_no = 1; double totalmarks,gpa; // Input // printf("Enter Number of students to process : "); scanf("%d", MAX_ROWS); fflush(stdin); for(i=0;i<MAX_ROWS;i++) { printf("Student #%d\n",student_no); printf("-----------\n"); student_no++; for(i=1;i<6;i++) { printf("Enter Student #%d's Grade for subject #%d",student_no,i); scanf("%c", &grade); if (grade = 'A') Array[MAX_ROWS][i] = 4.0; else if (grade = 'B') Array[MAX_ROWS][i] = 3.0; else if (grade = 'C') Array[MAX_ROWS][i] = 2.0; else if (grade = 'D') Array[MAX_ROWS][i] = 1.0; else if (grade = 'E') Array[MAX_ROWS][i] = 0.0; } } // Process // totalmarks = Array[MAX_ROWS][0] + Array[MAX_ROWS][1] + Array[MAX_ROWS][2] + Array[MAX_ROWS][3] + Array[MAX_ROWS][4]; gpa = totalmarks / subjects_taken; // Output // printf(" Examination Report "); printf("Student No. Subjects "); printf(" English Maths Science History Social Studies "); printf(" %d "); return 0; }



LinkBack URL
About LinkBacks




