1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

cs project!! really need your help!

Discussion in 'C' started by immaprog, Mar 20, 2011.

  1. immaprog

    immaprog New Member

    Joined:
    Mar 20, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Im a having a project defense and my program still has an error in it and I can't figure out what's wrong. Here's the code:

    Code:
    int main()
    {
        printf("\nPlease enter your name: ");
        scanf("%s", name);
        printf("\nHello %s!! Welcome to our quiz game!! ", &name);
        printf("\nPlease choose a category: ");
        printf("\nPress:\n1 if science\n2 if math\n3 if computers\n");
        printf("\nCHOICE: ");
        scanf("%s", &choice);
           
        if(choice == '1')
        science();
        if(choice == '2')
        math();
        if(choice == '3')
        computers();
        
        for(loop=0; loop<SIZE; loop++)
    
    
        srand(time(NULL));
        num = rand()%20+0;
        if (question[loop]==0)
    {
        switch(num)
    { 
               case 0: quest1(); break; // question 1
               case 1: quest2(); break; // question 2 
               case 2: quest3(); break; // question 3
               case 3: quest4(); break; // question 4
               case 4: quest5(); break; // question 5
               case 5: quest6(); break; // question 6
               case 6: quest7(); break; // question 7
               case 7: quest8(); break; // question 8
               case 8: quest9(); break; // question 9
               case 9: quest10(); break; // question 10
               case 10: quest11(); break; // question 11
               case 11: quest12(); break; // question 12
               case 12: quest13(); break; // question 13
               case 13: quest14(); break; // question 14
               case 14: quest15(); break; // question 15
               case 15: quest16(); break; // question 16
               case 16: quest17(); break; // question 17
               case 17: quest18(); break; // question 18
               case 18: quest19(); break; // question 19
               case 19: quest20(); break; // question 20
    }
               question[SIZE]==1;
    }
               else
               loop--;
    }     
               getch();
               return 0;
    
    }
    
    The error says "syntax error before return". I guess i should add or delete a curly brace but I've done that a lot of times and it still doesn't work.

    please help me!!! :crying:
     
  2. mahvine

    mahvine New Member

    Joined:
    Apr 15, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    remove the curly brace after the loop--; and it should be good to go
     

Share This Page