Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void) {
- // Declare variables
- int grade[5], g, classnum[9], c;
- char name[24], n;
- float GPA=0.0, grade_point=0.0, result=0.0;
- // Input student names implying amount of students
- for(n=0; n<25; n++) {
- scanf(" %s", &name[n]);
- printf("Please enter student names: %s.", name[n]);
- // Input number of classes
- for(c=0; c<10; c++) {
- scanf(" %d", &classnum[c]);
- printf("Please enter amount of classes (max.10): %d", classnum[c]);
- // Input grades
- for(g=0; g<=classnum; g++) {
- scanf(" %d", &grade[g]);
- printf("Please enter students' grades: %d.", grade[g]);
- }
- // Conversion of grades
- if (grade == "A"){
- grade_point = 4.0;
- }
- if (grade == "B"){
- grade_point = 3.0;
- }
- if (grade == "C")
- {
- grade_point =2.0;
- }
- if (grade == "D"){
- grade_point = 1.0;
- }
- if (grade == "F"){
- grade_point = 0.0;
- }
- // GPA formula
- result += grade_point[g];
- GPA = result/classnum[c];
- }
- }
- // Print results in a table
- printf("\n Student name \t Grades \t GPA");
- for(n=0; n<25; n++) {
- printf(" %s \t %d \t %f", name[n], grade[g], GPA);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement