new to programing need help!!

This is a discussion on new to programing need help!! within the C++ Programming forums, part of the General Programming Boards category; You can't have code between the int main() and the first brace. All that code should be after the brace. ...

  1. #16
    Registered User
    Join Date
    Jan 2005
    Posts
    7,340
    You can't have code between the int main() and the first brace. All that code should be after the brace. Also, watch typos, (like missing underscores when typing variable names).

  2. #17
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    You're also missing a semicolon here:
    Code:
    cout<<"Anual Income = $" <<anual_income<<endl
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #18
    Registered User
    Join Date
    Jan 2005
    Posts
    7,340
    No, that statement continues on the next line, so no semicolon is needed, although that's probably not the clearest way to do write it anyway.

  4. #19
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,047
    Oops.

    This
    Code:
    	if (anual_income<=12000)
    	tax_due=a;
    
    	else if ((anual_income>12000) && (anual_income<=25000))
    	tax_due=(anual_income-12000)*b;
    
    	else if (anual_income>25000)
    	tax due=((anual_income-25000)*c)+d;
    has several redundant expressions, marked in red. (That's what else statements do, you know. They only execute if the if was false.)
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C programing for DNA...
    By S16 in forum C Programming
    Replies: 9
    Last Post: 04-29-2009, 09:25 AM
  2. Programing microcontrollers in c
    By gorabhat in forum C Programming
    Replies: 2
    Last Post: 09-09-2008, 10:40 AM
  3. Human brain and programing
    By avgprogamerjoe in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 08-27-2007, 04:48 PM
  4. Non programing Question
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 06-21-2002, 06:55 AM
  5. C++ Programing
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 10-06-2001, 04:13 PM

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