Click here to Skip to main content
15,887,338 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello guys, i need to set if statement in code like this
C++
if x[i] < 0 and x[i] mod 2 = 0 then

This statement wont work, and i don't know why, can someone help?

x[i] must be less then 0 and x[i] must also be even numbers..?
Thanks!
Posted
Comments
Sergey Alexandrovich Kryukov 22-Feb-13 15:10pm    
Learn operator precedence!
—SA
[no name] 22-Feb-13 15:42pm    
I am C/C++ programmer and learning c#, i am not using pascla, this is for some girl to help her because she have programming in her school and they are using pascal, i hate pascal..

1 solution

It's been a long while since I used Pascal, but...have you tried with brackets?
if ((x[i] < 0) and ((x[i] mod 2) = 0)) then
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 22-Feb-13 15:10pm    
Correct, but outer brackets are totally redundant: this is not a C-like language without "then".
—SA
OriginalGriff 22-Feb-13 15:18pm    
I said it had been a long time! :laugh:
Sergey Alexandrovich Kryukov 22-Feb-13 15:25pm    
Yes, then I guess time can wipe or add brackets... :-)
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900