Home > Back-end >  Small white wondered, why can't use in VC6 2 <x <5 as a condition
Small white wondered, why can't use in VC6 2 <x <5 as a condition

Time:10-05

Small white wondered, why can't use in VC6 2 & lt; X<5 as a condition
For example below input 20 return is 26

Is used only & amp; & ?

O bosses teach

CodePudding user response:

Brother, this is a c + +, not mathematics, computer can't understand, you a

CodePudding user response:

reference 1st floor nana_aoe_2013 response:
brother, this is a c + +, not mathematics, computer can't understand, you a

I think this is not mainly because the compiler can't explain, mainly put the birth of the C language is to assemble into easy to understand programming language, the logic into basic unit free combination, reduce the entry barriers of the computer, polynomial of code to read and understand is not very convenient, not intuitive to let others understand his meaning,

CodePudding user response:

This is known as grammar, grammar rules, must have to do so, if you then, according to the C language grammar rules, they said from left to right, in turn, calculation, calculation is less than 2 x first, it is a logic value, the result is only 1 s and 0 s, get the results, compared with 5, it is lost, you the meaning of the original, so we can't write,

CodePudding user response:

Yes, this is a computer language, and mathematics, of course, there's a difference, since you all know how rules, you can't violate

CodePudding user response:

Grammar, it is a rule,

CodePudding user response:

First of all, there is nothing wrong with the grammar, as conditions
2 & lt; X<5 to perform 2 & lt; 0 or 1 x results, and then the results & lt; 5 the answer has been 1
This is not what you want!

All you need is
2 & lt; X & amp; & X<5
  • Related