Thread: Need help with an error!

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    2

    Need help with an error!

    Ya, I keep getting this error when I try to compile my code can anyone help?

    line 41: syntax error before or at: )
    See bolded line origin = 1

    Code:
    #include <stdio.h>
    
    int Calculate_duty(int, int, int, int);
    void Print_duty(int, int, int, int, int);
    
    
    int main(void)  
    {
                    
    char yes_or_no;
    int origin, category, quantity, price;
     
    printf("Do you have more customer form process (type: Y for yes, N for no)?\n");
    scanf("%c", &yes_or_no);  
    while ((yes_or_no != 'Y') && (yes_or_no != 'N'))
    {
    printf("You have to enter Y for Yes or N for No. Please try again. \n");
    /* Discard the end of line character or other characters */
    scanf("%c",&yes_or_no);
    }               
     
    while (yes_or_no = 'Y')
    {               
    printf("What is the origin of the goods (type: 1 for US, 2 for China, 3 for Brazil)?\n");
    scanf("%d", &origin);
    printf("What category of goods (type: 1 for food, 2 for clothing, 3 for wood)?\n");
    scanf("%d", &category);
    printf("What is the quantity?\n");
    scanf("%d", &quantity);
    printf("What is the unit price?\n");
    scanf("%d", &price);
    
    Print_duty(origin, category, quantity, price, Calculate_duty(price, quantity, category, origin))
    }
    }
    
    
    int Calculate_duty(int price, int quantity, int category, int origin)
    {
     
    int percent, duty;
     
    for (origin = 1)
    {
            for (category = 1)
    
                    percent = 0
    
            for (category = 2)
    
                    percent = 0
     
            for (category = 3)
    
                    percent = 0.05
    }
    for (origin = 2)  
    {
            for (category = 1)
     
                    percent = 0.02
    
            for (category = 2) 
    
                    percent = 0.03
    
            for (category = 3) 
     
                    percent = 0.04
    
    }
    for (origin = 3)
    {
            for (category = 1)
     
                    percent = 0.01
     
            for (category = 2)
    
                    percent = 0.02
    
            for (category = 3)
    
                    percent = 0.08
     
    }
    return duty = price*quantity*percent;
    }
    }
            
    void Print_duty(int origin, int category, int quantity, int price, int duty)
    {
            
    int percent, shipment;
    
     
    for (origin = 1)
    {
            for (category = 1)
     
                    percent = 0
    
            for (category = 2)
    
    
                    percent = 0
     
            for (category = 3)
    
                    percent = 0.05
            
    }
    for (origin = 2)
    {
            for (category = 1)
     
                    percent = 0.02
     
            for (category = 2) 
    
                    percent = 0.03
    
    
            for (category = 3) 
     
                    percent = 0.04
    
    }
    for (origin = 3)
    {
            for (category = 1)
     
                    percent = 0.01
     
            for (category = 2)
     
                    percent = 0.02
    
            for (category = 3)
    
                    percent = 0.08
     
    }
    
    shipment = quantity*price;
    
    printf("Origin Category Quantity Unit Price Shipment Tax Rate Duty\n");
    printf("%d \t %d \t %d \t %.2d \t %.2d \t %.2d \t %.2d", &origin, &category, &quantity, &percent, &duty);
    printf("The amount due is %.2d \n", &duty);
    printf("**********************************************************");
     
    }

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Well you use = where you should be using == in a whole lot of places.

    And look backwards from the error line to find a line without a semi-colon.

    Then look forward, to see a whole lot of lines without ;
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    596
    Not to mention all the for(...) statements with only a single expression (and no semicolons) inside the parentheses...

  4. #4
    Registered User
    Join Date
    Nov 2010
    Posts
    2
    Well, I wasn't sure how if statements worked and for statements seemed the same so I kinda used those o.O

    Am new to C so I don't know all the different things like that yet :P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM