2 Replies - 196 Views - Last Post: 26 March 2011 - 10:46 AM Rate Topic: -----

#1 roxya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 19-March 11

Comparison Operator Syntax Question

Posted 26 March 2011 - 10:39 AM

Why can't this work?

    else if (income >= 16751 && <= 68000)


If I try to do it in Visual Studio 2010, it gives me a syntax error.
Is This A Good Question/Topic? 0
  • +

Replies To: Comparison Operator Syntax Question

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1137
  • View blog
  • Posts: 7,099
  • Joined: 07-September 06

Re: Comparison Operator Syntax Question

Posted 26 March 2011 - 10:44 AM

It doesn't work because you are trying to specify a range for a variable to be within, the only problem is that most programming languages don't like ranges and instead require you to be specific. This should work:
else if(income >= 16751 && income <= 68000)


See the difference?

Hope that helps.
Was This Post Helpful? 1
  • +
  • -

#3 roxya  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 19-March 11

Re: Comparison Operator Syntax Question

Posted 26 March 2011 - 10:46 AM

Ooh, I see it now. Thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1