Thread: can't find the error

  1. #1
    Registered User
    Join Date
    Oct 2019
    Posts
    5

    can't find the error

    Code:
    error: expected identifier or ‘(’ before ‘{’ token
       15 | {
    i can't find the error because it's in the beginning of the code and i had no idea, please help me

    Code:
    #include <stdio.h>
    #include <limits.h>
    
    
    int maxi, mini, subject, A,B,C,D,E;
    int score[60];
    
    
    void scoregrade(int score[60]);
    void average(float, float);
    float countgpa, gpa;
    void maximini(int score[60]);
    
    
    int main();
    {
            int maxi = INT_MIN;
            int mini = INT_MAX;
        subject = 1;
            while(subject <= 6){ //nanti ganti
                for(subject=1; subject <=6; subject++){
                    printf("Please Enter The Score per Subject: ");
                                    scanf("%d", &score[subject]);
                                    scoregrade(score);
                                    subject++;
                    printset();
                    average(countgpa, gpa);
                    }
                    maximini(score);}
    }                                                                                                                       
    void maximini(int score[60])
    {
            for(subject=0; subject <=6; subject++){ // ganti juga
            if (score[subject] >= maxi){maxi = score[subject];}
            else if (score[subject] <= mini){mini = score[subject];}
            printf("Max = %d\n", maxi);
            printf("Min = %d\n", mini);}
    }
    
    
    void printset()
    {
        printf("A = %d\n", A);
        printf("B = %d\n", B);
        printf("C = %d\n", C);
        printf("D = %d\n", D);
        printf("E = %d\n", E);
    }
    
    
    void scoregrade(int score[60])
    {
        for(subject = 0; subject <= 6; subject++){
            if (score[subject] >= 85)
                {A++; printf("Your score is:%d => grade A\n", score[subject]);}
                    else if (score[subject] >= 70)
                        {B++; printf("Your score is:%d => grade B\n", score[subject]);}
                            else if (score[subject] >= 60)
                                {C++; printf("Your score is:%d => grade C\n", score[subject]);}
                                    else if (score[subject] >= 55)
                                        {D++; printf("Your score is:%d => grade D\n", score[subject]);}
                                            else {E++; printf("Your score is:%d => grade E\n", score[subject]);}
        }
    }
    
    
    void average(float countgpa, float gpa)
    {
        for (subject = 0; subject <= 6; subject++){
        countgpa=(4*A*3)+(3*B*3)+(2*C*3)+(1*D*3)+(0*E*3);
        gpa=countgpa/18;
        printf("GPA Semester 1: %.2f\n", gpa);}
    }
    thank you

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Look at this line:
    Code:
    int main();
    You placed a semi-colon at the end of the line that shouldn't be there.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2019
    Posts
    5
    Quote Originally Posted by laserlight View Post
    Look at this line:
    Code:
    int main();
    You placed a semi-colon at the end of the line that shouldn't be there.

    thank you

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can you find the error?
    By neeha_khan in forum C++ Programming
    Replies: 20
    Last Post: 04-15-2013, 07:02 AM
  2. Cannot find my error
    By Genxi in forum C Programming
    Replies: 5
    Last Post: 09-24-2012, 02:32 AM
  3. Cant Find Error
    By Toonzaka in forum C Programming
    Replies: 3
    Last Post: 08-10-2008, 02:00 PM
  4. Can't find error
    By shadowsora15 in forum C++ Programming
    Replies: 5
    Last Post: 05-26-2007, 04:00 AM
  5. Cant find the error
    By Coder87C in forum C Programming
    Replies: 8
    Last Post: 06-19-2005, 01:57 AM

Tags for this Thread