Thread: Undefined reference to main

  1. #1
    Registered User
    Join Date
    Apr 2017
    Posts
    1

    Undefined reference to main

    I am getting the error message below when I try to make my source code file.

    gcc -o grading.c -lm
    /usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/crt1.o: In function `_start':
    (.text+0x20): undefined reference to `main'
    collect2: ld returned 1 exit status
    make: *** [grading] Error 1


    the source code \/
    insert
    Code:
    /*
     ********************************************************
     ***
     ***
     */
    
    #include <stdio.h>
    #include <stdlib.h>
    
    int main ()
    { /* main */
       /*
        ***************************
        *** Declaration Section ***
        ***************************
        *
        *****************************
        * Named Constant Subsection *
        *****************************
        *
        * A_grade                    the minimum grade a student needs to get an A.
        * B_grade                    the minimum grade a student needs to get a B.
        * C_grade                    the minimum grade a student needs to get a C.
        * D_grade                    the minimum grade a student needs to get a D.
        * F_grade                    the minimum grade a student needs to get an F.
        * initial_sum                initial sum that various things are set to.
        * max_pos_scr                the max score possible in the class.
        * spring                     value used to represent the spring semester.
        * fall                       value used to represent the fall semester.
        * program_failure_code       used to exit the program due to idiotproofing.
        * quiz_one_points            the max points available for quiz one.
        * quiz_two_points            the max points available for quiz two.
        * quiz3_points               the max points available for quiz three.
        * quiz_four_points           the max points available for quiz four.
        * pp1_points                 the maximum number of points available for pp1
        * pp2_points                 the maximum number of points available for pp2
        * pp3_points                 the maximum number of points available for pp3
        * lab_points                 the max pts available for labs.
        * final_exam_points          the max pts available for the final exam.
        * first_student              number representing the 1st value in an array
        */
    
        const float A_grade = 4500;
        const float B_grade = 4000;
        const float C_grade = 3500;
        const float D_grade = 3000;
        const float F_grade = 0;
        const float initial_sum = 0;
        const float max_pos_scr = 5000.0;
        const int spring = 1;
        const int fall = 2; 
        const int program_failure_code = -1;
        const int quiz_one_points = 30;
        const int quiz_two_points = 170;
        const int quiz3_points = 130;
        const int quiz_four_points = 115;
        const int pp1_points = 250;
        const int pp2_points = 1000;
        const int pp3_points = 2000;
        const int lab_points = 505;
        const int final_exam_points = 800;
        const int first_student = 0;
        const int zero = 0;
        const int one = 1;
    
        
       /*
        *****************************
        * Local Variable Subsection *
        *****************************
        * 
        * quiz_one_score                 array that holds the scores for quiz one.
        * quiz_two_score                 array that holds the scores for quiz two.
        * quiz3_score                    array that holds the scores for quiz three
        * quiz_four_score                array that holds the scores for quiz four.
        * pp1_score                      an array that holds the scores for pp1.
        * pp2_score                      an array that holds the scores for pp2.
        * pp3_score                      an array that holds the scores for pp3.
        * lab_score                      array holding the lab scores
        * fnl_exm_scr                    array holding the final exam scores
        * overall_score                  array holding the overall scores
        * stdt_prcntg_scr_score          array holding overall percentage scores
        * student_ID                     an array that holds the student ID's.
        * student_letter_grade           array holding student letter grades.
        * overall_score_sum              sum of the overall scores of all students.
        * overall_score_mean             mean of the overall scores of all students
        * quiz_one_score_sum             sum of the quiz one scores of all students
        * quiz_one_score_mean            mean quiz one scores of all students.
        * quiz_two_score_sum             sum of the quiz two scores
        * quiz_two_score_mean            mean quiz two scores
        * quiz3_score_sum                sum of the quiz three scores 
        * quiz3_score_mean               mean quiz three scores
        * quiz_four_score_sum            sum of quiz four scores.
        * quiz_four_score_mean           mean quiz four scores of all students.
        * pp1_score_sum                  sum of the pp1 scores of all students.
        * pp1_score_mean                 mean of the pp1 scores of all students.
        * pp2_score_sum                  sum of the pp2 scores of all students.
        * pp2_score_mean                 mean of the pp2 scores of all students.
        * pp3_score_sum                  sum of the pp3 scores of all students.
        * pp3_score_mean                 mean of the pp3 scores of all students.
        * lab_score_sum                  sum of the lab scores of all students.
        * lab_score_mean                 mean of the lab scores of all students.
        * fnl_exm_scr_sum                sum of final exam scores of all students.
        * fnl_exm_scr_mean                mean final exam scores of all students.
        * quiz1_lowest_score             the lowest quiz one score.             
        * quiz2_lowest_score             the lowest quiz two score.                                         
        * quiz3_lowest_score             the lowest quiz three score.         
        * quiz4_lowest_score             the lowest quiz four score.
        * pp1_lowest_score               the lowest pp1 score.             
        * pp2_lowest_score               the lowest pp2 score.                                         
        * pp3_lowest_score               the lowest pp3 score. 
        * lab_lowest_score               the lowest lab score. 
        * final_exam_lowest_score        the lowest final exam score. 
        * quiz1_highest_score            the highest quiz one score.             
        * quiz2_highest_score            the highest quiz two score.                                         
        * quiz3_highest_score            the highest quiz three score.         
        * quiz4_highest_score            the highest quiz four score.
        * pp1_highest_score              the highest pp1 score.             
        * pp2_highest_score              the highest pp2 score.                                         
        * pp3_highest_score              the highest pp3 score. 
        * lab_highest_score              the highest lab score. 
        * final_exam_highest_score       the highest final exam score.    
        * stdt_prcntg_scr_sum            sum of overall percentage scores.
        * stdt_prcntg_scr_mean           mean overall percentage scores.
        * low_overall_percentage_score   the lowest overall percentage score.
        * high_overall_percentage_score  the highest overall percentage score.
        * year                           reps the year the student was enrolled.
        * semester                       reps the fall or spring semester.
        * num_students                   num students enrolled in the class.
        * student                        reps the position in an array of students.
        * num_As                         num who received an A in the class.
        * num_Bs                         num who received a B in the class.
        * num_Cs                         num who received a C in the class.
        * num_Ds                         num who received a D in the class.
        * num_Fs                         num who received an F in the class.
        * 
        */
         
        float* quiz_one_score = (float*)NULL;
        float* quiz_two_score = (float*)NULL;
        float* quiz3_score = (float*)NULL;
        float* quiz_four_score = (float*)NULL;
        float* pp1_score = (float*)NULL;
        float* pp2_score = (float*)NULL;
        float* pp3_score = (float*)NULL;
        float* lab_score = (float*)NULL;
        float* fnl_exm_scr = (float*)NULL;
        float* overall_score = (float*)NULL;
        float* stdt_prcntg_scr = (float*)NULL;
        int* student_ID = (int*)NULL;
        char* student_letter_grade = (char*)NULL;
        float overall_score_sum;
        float overall_score_mean;
        float quiz_one_score_sum;
        float quiz_one_score_mean;
        float quiz_two_score_sum;
        float quiz_two_score_mean;
        float quiz3_score_sum;
        float quiz3_score_mean;
        float quiz_four_score_sum;
        float quiz_four_score_mean;
        float pp1_score_sum;
        float pp1_score_mean;
        float pp2_score_sum;
        float pp2_score_mean;
        float pp3_score_sum;
        float pp3_score_mean;
        float pp4_score_sum;
        float pp4_score_mean;
        float lab_score_sum;
        float lab_score_mean;
        float fnl_exm_scr_sum;
        float fnl_exm_scr_mean;
        float quiz1_lowest_score;
        float quiz2_lowest_score;
        float quiz3_lowest_score;
        float quiz4_lowest_score;
        float pp1_lowest_score;
        float pp2_lowest_score;
        float pp3_lowest_score;
        float lab_lowest_score;
        float final_exam_lowest_score;
        float quiz1_highest_score;
        float quiz2_highest_score;
        float quiz3_highest_score;
        float quiz4_highest_score;
        float pp1_highest_score;
        float pp2_highest_score;
        float pp3_highest_score;
        float lab_highest_score;
        float final_exam_highest_score;
        float stdt_prcntg_scr_sum;
        float stdt_prcntg_scr_mean;
        float low_overall_percentage_score;
        float high_overall_percentage_score;
        int year;
        int semester;
        int num_students;
        int student;
        int num_As;
        int num_Bs;
        int num_Cs;
        int num_Ds;
        int num_Fs;
    
       /* 
        *************************
        *** Execution Section ***
        *************************
        *
         
       /*
        ************************
        *** Input Subsection ***
        ************************
        *
        */
        
       /*
        * Input the year and semester (1 for spring, 2 for fall).
        */
        scanf("%d %d", &year, &semester);
       /*
        * Idiot-proof the input for the year and semester.
        */
        if (year < zero) {
           /*
            * Output the error message and exit 
            */
            printf("ERROR: unknown year and semester code %d.\n", semester);
            exit(program_failure_code);
        }
    
       /*
        * Input the number of students enrolled in the class.
        */
        scanf("%d", &num_students);
       /*
        * Idiot-proof the input for the number of students enrolled.
        */
        if (num_students < one) {
           /*
            * Output the error message and exit 
            */
            printf("ERROR: unknown num students code %d.\n", num_students);
            exit(program_failure_code);
        }
        
       /* 
        * Allocate and Idiotproof each array.
        */
        student_ID = (int*)malloc(sizeof(int)*num_students);
        if (student_ID == (int*)NULL {
            printf("ERROR: the attempt to allocate\n");
            printf(" student ID failed.\n");
            exit(program_failure_code);
        } /* if (student_ID == (int*)NULL */
        
        quiz_one_score = (float*)malloc(sizeof(float)*num_students);
        if (quiz_one_score == (float*)NULL {
            printf("ERROR: the attempt to allocate\n");
            printf(" quiz one score failed.\n");
            exit(program_failure_code);
        } /* if (quiz_one_score == (float*)NULL */
        
        quiz_two_score = (float*)malloc(sizeof(float)*num_students);
        if (quiz_two_score == (float*)NULL {
            printf("ERROR: the attempt to allocate\n");
            printf(" quiz two score failed.\n");
            exit(program_failure_code);
        } /* if (quiz_two_score == (float*)NULL */
        
        quiz3_score = (float*)malloc(sizeof(float)*num_students);
        if (quiz3_score == (float*)NULL {
            printf("ERROR: the attempt to allocate\n");
            printf(" quiz three score failed.\n");
            exit(program_failure_code);
        } /* if (quiz3_score == (float*)NULL */
        
        quiz_four_score = (float*)malloc(sizeof(float)*num_students);
        if (quiz_four_score == (float*)NULL {
            printf("ERROR: the attempt to allocate\n");
            printf(" quiz four score failed.\n");
            exit(program_failure_code);
        } /* if (quiz_four_score == (float*)NULL */
        
        pp1_score = (float*)malloc(sizeof(float)*num_students);
        if (pp1_score == (float*)NULL {
            printf("ERROR: the attempt to allocate\n");
            printf(" pp1 score failed.\n");
            exit(program_failure_code);
        } /* if (pp1_score == (float*)NULL */
        
        pp2_score = (float*)malloc(sizeof(float)*num_students);
        if (pp2_score == (float*)NULL {
            printf("ERROR: the attempt to allocate\n");
            printf(" pp2 score failed.\n");
            exit(program_failure_code);
        } /* if (pp2_score == (float*)NULL */
        
        pp3_score = (float*)malloc(sizeof(float)*num_students);
        if (quiz_one_score == (float*)NULL {
            printf("ERROR: the attempt to allocate\n");
            printf(" pp3 score failed.\n");
            exit(program_failure_code);
        } /* if (pp3_score == (float*)NULL */
        
        lab_score_score = (float*)malloc(sizeof(float)*num_students);
        if (lab_score == (float*)NULL {
            printf("ERROR: the attempt to allocate\n");
            printf(" lab score failed.\n");
            exit(program_failure_code);
        } /* if (lab_score == (float*)NULL */
        
        fnl_exm_scr_score = (float*)malloc(sizeof(float)*num_students);
        if (fnl_exm_scr_score == (float*)NULL {
            printf("ERROR: the attempt to allocate\n");
            printf(" final exam score failed.\n");
            exit(program_failure_code);
        } /* if (fnl_exm_scr_score == (float*)NULL */
    
        student_letter_grade = (char*)malloc(sizeof(char)*num_students);
        if (student_letter_grade == (char*)NULL) {
            printf("ERROR: the attempt to allocate\n");
            printf(" the student's letter grade failed.\n");
            exit(program_failure_code);
        } /* if (student_letter_grade == (char*)NULL) */
        
        stdt_prcntg_scr = (float*)malloc(sizeof(float)*num_students);
        if (stdt_prcntg_scr == (float*)NULL) {
            printf("ERROR: the attempt to allocate\n");
            printf(" the student's overall percentage score failed.\n");
            exit(program_failure_code);
        } /* if (stdt_prcntg_scr == (float*)NULL) */
    
       /* 
        * make a for loop that will read all the information for each student
        */
        for (student = first_student; student < num_students; student++) {
           /*
            * Input each of the elements from the database into each array.
            */
            scanf("%d %f %f %f %f %f %f %f %f %f",
                &student_ID[student],
                &quiz_one_score[student], &quiz_two_score[student],
                &quiz3_score[student], &quiz_four_score[student],
                &pp1_score[student], &pp2_score[student], &pp3_score[student],
                &lab_score[student], &fnl_exm_scr[student]);
            printf("Done inputting data for student #%d:\n", student);
            printf("student_ID[%d]:      %f\n", student, student_ID[student]);
            printf("quiz_one_score[%d]:  %f\n", student, quiz_one_score[student]);
            printf("quiz_two_score[%d]:  %f\n", student, quiz_two_score[student]);
            printf("quiz3_score[%d]:     %f\n", student, quiz3_score[student]);
            printf("quiz_four_score[%d]: %f\n", student, quiz_four_score[student]);
            printf("pp1_score[%d]:       %f\n", student, pp1_score[student]);
            printf("pp2_score[%d]:       %f\n", student, pp2_score[student]);
            printf("pp3_score[%d]:       %f\n", student, pp3_score[student]);
            printf("fnl_exm_scr[%d]:     %f\n", student, fnl_exm_scr[student]);
        } /* for student */
        /* insert idiotproofing here */
         
         
       /*
        ******************************
        *** Calculation Subsection ***
        ******************************
        */
        
       /* Calculate each students overall score, overall percentage 
        *score for the semester and their letter grade*/
        for (student = first_student; student<num_students; student++) {
            overall_score[student] = quiz_one_score[student] 
            + quiz_two_score[student]
            + quiz3_score[student] + quiz_four_score[student] 
            + pp1_score[student] + 
            pp2_score[student] + pp3_score[student] 
            + lab_score[student] + fnl_exm_scr[student];
            stdt_prcntg_scr[student] = overall_score[student]/max_pos_scr;
            if (overall_score >= A_grade) {
                student_letter_grade[student] = A;
            } /* if (overall_score >= A_grade) */
            else if (overall_score >= B_grade) {
                student_letter_grade[student] = B;
            } /* if (overall_score >= B_grade) */
            else if (overall_score >= C_grade) {
                student_letter_grade[student] = C;
            } /* if (overall_score >= C_grade) */
            else if (overall_score >= D_grade) {
                student_letter_grade[student] = D;
            } /* if (overall_score >= D_grade) */
            else if (overall_score >= F_grade) {
                student_letter_grade[student] = F;
            } /* if (overall_score >= F_grade) */
        }
       /* calculate the score means by first adding up all the scores*/
        overall_score_sum = initial_sum;
        quiz_one_score_sum = initial_sum;
        quiz_two_score_sum = initial_sum;
        quiz3_score_sum = initial_sum;
        quiz_four_score_sum = initial_sum;
        pp1_score_sum = initial_sum;
        pp2_score_sum = initial_sum;
        pp3_score_sum = initial_sum;
        lab_score_sum = initial_sum;
        fnl_exm_scr_sum = initial_sum;
        for (student = first_student; student < num_students; student++) {
            /* calculate the sum of the overall scores */
            overall_score_sum += overall_score[student];
            /* calculate the sum of the mean scores for quiz one */
            quiz_one_score_sum += quiz_one_score[student];
            /* calculate the sum of the mean scores for quiz two */
            quiz_two_score_sum += quiz_two_score[student];
            /* calculate the sum of the mean scores for quiz three */
            quiz3_score_sum += quiz3_score[student];
            /* calculate the sum of the mean scores for quiz four */
            quiz_four_score_sum += quiz_four_score[student];
            /* calculate the sum of the mean scores for pp1 */
            pp1_score_sum += pp1_score[student];
            /* calculate the sum of the mean scores for pp2 */
            pp2_score_sum += pp2_score[student];
            /* calculate the sum of the mean scores for pp3 */
            pp3_score_sum += pp3_score[student];
            /* calculate the sum of the mean scores for the labs */
            lab_score_sum += lab_score[student];
            /* calculate the sum of the mean scores for the final exams */
            fnl_exm_scr_sum += fnl_exm_scr[student];
        }
       /* calculate the mean score for all the students overall. */
        overall_score_mean = overall_score_sum/num_students;
       /* calculate the mean score for quiz one. */
        quiz_one_score_mean = quiz_one_score_sum/num_students;
       /* calculate the mean score for quiz two. */
        quiz_two_score_mean = quiz_two_score_sum/num_students;
       /* calculate the mean score for quiz three. */
        quiz3_score_mean = quiz3_score_sum/num_students;
       /* calculate the mean score for quiz four. */
        quiz_four_score_mean = quiz_four_score_sum/num_students;
       /* calculate the mean score for pp1. */
        pp1_score_mean = pp1_score_sum/num_students;
       /* calculate the mean score for pp2. */
        pp2_score_mean = pp2_score_sum/num_students;
       /* calculate the mean score for pp3. */
        pp3_score_mean = pp3_score_sum/num_students;
       /* calculate the mean score for lab. */
        lab_score_mean = lab_score_sum/num_students;
       /* calculate the mean score for the final exam. */
        fnl_exm_scr_mean = fnl_exm_scr_sum/num_students;
    
       /*
        * Calculate the lowest quiz one score score of all the students.
        */
        quiz1_lowest_score = quiz_one_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (quiz_one_score[student] < quiz1_lowest_score) {
                quiz1_lowest_score = quiz_one_score[student];
            } /* if (quiz_one_score[student] < quiz1_lowest_score) */
        } /* for student */
       /*
        * Calculate the lowest quiz two score score of all the students.
        */
        quiz2_lowest_score = quiz_two_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (quiz_two_score[student] < quiz2_lowest_score) {
                quiz2_lowest_score = quiz_two_score[student];
            } /* if (quiz_two_score[student] < quiz2_lowest_score) */
        } /* for student */
       /*
        * Calculate the lowest quiz three score score of all the students.
        */
        quiz3_lowest_score = quiz3_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (quiz3_score[student] < quiz3_lowest_score) {
                quiz3_lowest_score = quiz3_score[student];
            } /* if (quiz3_score[student] < quiz3_lowest_score) */
        } /* for student */
       /*
        * Calculate the lowest pp1 score score of all the students.
        */
        pp1_lowest_score = pp1_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (pp1_score[student] < pp1_lowest_score) {
                pp1_lowest_score = pp1_score[student];
            } /* if (pp1_score[student] < pp1_lowest_score) */
        } /* for student */
       /*
        * Calculate the lowest pp2 score score of all the students.
        */
        pp2_lowest_score = pp2_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (pp2_score[student] < pp2_lowest_score) {
                pp2_lowest_score = pp2_score[student];
            } /* if (pp2_score[student] < pp2_lowest_score) */
        } /* for student */
       /*
        * Calculate the lowest pp3 score score of all the students.
        */
        pp3_lowest_score = pp3_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (pp3_score[student] < pp3_lowest_score) {
                pp3_lowest_score = pp3_score[student];
            } /* if (pp3_score[student] < pp3_lowest_score) */
        } /* for student */
       /*
        * Calculate the lowest lab score score of all the students.
        */
        lab_lowest_score = quiz_one_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (lab_score[student] < lab_lowest_score) {
                lab_score = lab_score[student];
            } /* if (lab_score[student] < lab_score) */
        } /* for student */
       /*
        * Calculate the lowest final exam score score of all the students.
        */
        fnl_exm_scr = fnl_exm_scr[first_student];
        for (student = first_student; student < num_students; student++) {
            if (fnl_exm_scr[student] < final_exam_lowest_score) {
                final_exam_lowest_score = fnl_exm_scr[student];
            } /* if (fnl_exm_scr[student] < final_exam_lowest_score) */
        } /* for student */
        
       /*
        * Calculate the highest quiz one score score of all the students.
        */
        quiz1_highest_score = quiz_one_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (quiz_one_score[student] > quiz1_highest_score) {
                quiz1_highest_score = quiz_one_score[student];
            } /* if (quiz_one_score[student] > quiz1_highest_score) */
        } /* for student */
        quiz2_highest_score = quiz_two_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (quiz_two_score[student] > quiz2_highest_score) {
                quiz2_highest_score = quiz_two_score[student];
            } /* if (quiz_two_score[student] > quiz2_highest_score) */
        } /* for student */
        quiz3_highest_score = quiz3_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (quiz3_score[student] > quiz3_highest_score) {
                quiz3_highest_score = quiz3_score[student];
            } /* if (quiz3_score[student] > quiz3_highest_score) */
        } /* for student */
        quiz4_highest_score = quiz_four_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (quiz_four_score[student] > quiz4_highest_score) {
                quiz4_highest_score = quiz_four_score[student];
            } /* if (quiz_four_score[student] > quiz4_highest_score) */
        } /* for student */
        pp1_highest_score = pp1_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (pp1_score[student] > pp1_highest_score) {
                pp1_highest_score = pp1_score[student];
            } /* if (pp1_score[student] > pp1_highest_score) */
        } /* for student */
        pp2_highest_score = pp2_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (pp2_score[student] > pp2_highest_score) {
                pp2_highest_score = pp2_score[student];
            } /* if (pp2_score[student] > pp2_highest_score) */
        } /* for student */
        pp3_highest_score = pp3_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (pp3_score[student] > pp3_highest_score) {
                pp3_highest_score = pp3_score[student];
            } /* if (pp3_score[student] > pp3_highest_score) */
        } /* for student */
        lab_highest_score = lab_score[first_student];
        for (student = first_student; student < num_students; student++) {
            if (lab_score[student] > lab_highest_score) {
                lab_highest_score = lab_score[student];
            } /* if (lab_score[student] > lab_highest_score) */
        } /* for student */
        final_exam_highest_score = fnl_exm_scr[first_student];
        for (student = first_student; student < num_students; student++) {
            if (fnl_exm_scr[student] > final_exam_highest_score) {
                final_exam_highest_score = fnl_exm_scr[student];
            } /* if (fnl_exm_scr[student] > final_exam_highest_score) */
        } /* for student */
        
       /*
        * Calculate the number of students who received an A.
        */
        for (student = first_student; student < num_students; student++) {
            if (overall_score[student] >= A_grade) {
                num_As++;
            } /* if (overall_score[student] >= A_grade) */
        } /* for student */
       /*
        * Calculate the number of students who received a B.
        */
        for (student = first_student; student < num_students; student++) {
            if (overall_score[student] >= B_grade) {
                num_Bs++;
            } /* if (overall_score[student] >= B_grade) */
        } /* for student */
       /*
        * Calculate the number of students who received a C.
        */
        for (student = first_student; student < num_students; student++) {
            if (overall_score[student] >= C_grade) {
                num_Cs++;
            } /* if (overall_score[student] >= C_grade) */
        } /* for student */
       /*
        * Calculate the number of students who received a D.
        */
        for (student = first_student; student < num_students; student++) {
            if (overall_score[student] >= D_grade) {
                num_Ds++;
            } /* if (overall_score[student] >= D_grade) */
        } /* for student */
       /*
        * Calculate the number of students who received an F.
        */
        for (student = first_student; student < num_students; student++) {
            if (overall_score[student] >= F_grade) {
                num_Fs++;
            } /* if (overall_score[student] >= F_grade) */
        } /* for student */
        
       /*
        * Calculate the mean overall percentage score of all students in the course
        */
        for (student = first_student; student<num_students; student++) {
            stdt_prcntg_scr_sum += stdt_prcntg_scr[student];
        } /* for student */
        stdt_prcntg_scr_mean = stdt_prcntg_scr_sum/num_students;
    
       /* 
        * Calculate lowest overall percentage score of students in the course.
        */
        low_overall_percentage_score = stdt_prcntg_scr[first_student];
        for (student = first_student; student < num_students; student++) {
            if (stdt_prcntg_scr[student] < low_overall_percentage_score) {
                low_overall_percentage_score = stdt_prcntg_scr[student];
            } /* if (stdt_prcntg_scr[student] < low_overall_percentage_score) */
        } /* for student */
        
       /* 
        * Calculate highest overall percentage score of students in the course.
        */
        high_overall_percentage_score = stdt_prcntg_scr[first_student];
        for (student = first_student; student < num_students; student++) {
            if (stdt_prcntg_scr[student] > high_overall_percentage_score) {
                high_overall_percentage_score = stdt_prcntg_scr[student];
            } /* if (stdt_prcntg_scr[student] > high_overall_percentage_score) */
        } /* for student */
        
       /*
        *************************
        *** Output Subsection ***
        *************************
        */
         
       /*
        * output the name of the course, the semester, the year, in that order
        * output the number of students.
        * output each of the items that were calculated, 
        * in the same order as the calculation subsection
        */
        
        free(fnl_exm_scr);
        fnl_exm_scr = (float*)NULL;
        free(lab_score);
        lab_score = (float*)NULL;
        free(pp3_score);
        pp3_score = (float*)NULL;
        free(pp2_score);
        pp2_score = (float*)NULL;
        free(pp1_score);
        pp1_score = (float*)NULL;
        free(quiz_four_score);
        quiz_four_score = (float*)NULL;
        free(quiz3_score);
        quiz3_score = (float*)NULL;
        free(quiz_two_score);
        quiz_two_score = (float*)NULL;
        free(quiz_one_score);
        quiz_one_score = (float*)NULL;
        free(student_ID);
        student_ID = (int*)NULL;
    
    } /* main */

  2. #2
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    That is some horrific looking code!

    Anyway, your compile line is wrong. If you actually ran that line you'll be lucky if your grading.c file wasn't deleted.

    It should be: gcc -Wall -W grading.c -lm -o grading

    The -o flag tells gcc what you want the executable to be called. If you don't use the flag the executable will be called a.out by default (or possibly a.exe on windows). The -Wall and -W flags increase the warning level.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 09-23-2016, 01:40 PM
  2. undefined reference to `main' - Binary Search Error
    By scrfix in forum C Programming
    Replies: 8
    Last Post: 04-16-2012, 09:55 PM
  3. Undefined reference ?
    By Holymanus in forum C Programming
    Replies: 6
    Last Post: 01-07-2011, 09:15 AM
  4. Undefined Reference to Main Error
    By rrc55 in forum C Programming
    Replies: 10
    Last Post: 07-15-2009, 01:32 PM
  5. Replies: 8
    Last Post: 04-23-2009, 05:08 AM

Tags for this Thread