error message

This is a discussion on error message within the C Programming forums, part of the General Programming Boards category; I keep getting a syntax error message right before the statetax in the while loop. But there isn't anything there ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    18

    error message

    I keep getting a syntax error message right before the statetax in the while loop. But there isn't anything there
    Code:
    int main(void)
    
    {
            double salary = 0,sumtax = 0;
            double fedtax = 0.17;
            double statetax = 0.03;
    
       while (scanf("%lf",&salary) ==1)
            {
             fedtax = salary * fedtax
             statetax = salary * statetax
             sumtax = (salary - fedtax - statetax)
    
            printf("Value of Salary %lf", sumtax);
            }
    return 0;
    }
    Last edited by ke121885; 10-18-2009 at 04:46 PM. Reason: updated code

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You are right, there isn't anything there. Which is the problem, since the error message states "missing ; before statetax". Look before statetax, and see where the semicolon is missing.

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    18

    pause

    In this Code:
    Code:
    int main(void)
    
    {
            double salary = 0,sumtax = 0;
            double fedtax = 0.17;
            double statetax = 0.03;
    
            printf("Enter your gross salary\n",salary);
       while (scanf("%lf",&salary) ==1);
            {
             fedtax = salary * fedtax;
             statetax = salary * statetax;
             salary = (salary - fedtax - statetax);
             sumtax = (fedtax + statetax);
            }
            printf("Value of Salary %lf\n", salary);
            printf("Value of Taxes %lf\n", sumtax);
    
    return 0;
    }
    I am getting a pause after the salary prompt and I can't actually get the answers until I hit ctrl D. Why does this keep happening?

  4. #4
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,652
    So your answer for a missing a semicolon is to just add semicolons everywhere? Why don't you actually read your ........ing book?

  5. #5
    Registered User
    Join Date
    Sep 2009
    Posts
    18
    if I asking for help on a board that is used for help why are people getting mad? I haven't been doing programming forever and am just trying to learn what I am doing wrong. Sorry I am a bother but not everyone gets programming the first time around.

    ....and I do read my book but the one my class is using is sooo old that the teacher decided to not use it and just go on his own experience....so like I said I am TRYING to learn....

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    punctuationcanbeimportantithelpstodeterminethemean ingofwhatsgoingonandsoitssomethingyouneedtolearnho wtouse

    You should know why you do something, and not just type things at random. Tell us why you strewed semicolons throughout your program seemingly at random and we'll go from there.

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    while (scanf("%lf",&salary) ==1); <-- must not have semicolon there!

  8. #8
    Registered User
    Join Date
    Sep 2009
    Location
    USA
    Posts
    63
    Quote Originally Posted by rags_to_riches View Post
    So your answer for a missing a semicolon is to just add semicolons everywhere? Why don't you actually read your ........ing book?
    "I FEEL" its so not cool man...you know they're many other ways to express that right?

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21