1. ## beginner's question :D

Hi all
i am new to c programming (quite new to any type of programming, having only done a bit of python before), and i would just like to know if its possible (and how?) in c programming to:

use an if statement with this sorta functionality

if (condition) OR (condition)

so that if either condition is satisfied the if statement is satisfied?

thanksss!

2. Of course...tutorial is here.

3. ok cool thanks!

that clarifies things for me
so if i had a statement like this

if (condition) OR (condition) OR (condition)

and the 'false' of each of these conditions returns -1
and the 'true' returns a positive integer?

i would do something like

Code:
```if ((condition1 + 1)|(condition2 + 1)|(condition3 + 1) != 0){
etc etc```

4. and the 'false' of each of these conditions returns -1
and the 'true' returns a positive integer?
So, you mean that if the variable's value is -1, the condition is false, but if the value is greater than zero, the condition is true? What if the value is 0?

i would do something like
Probably not. Assuming that a non-negative value means a true condition, you might do something like this:
Code:
```if (condition1 >= 0 || condition2 >= 0 || condition3 >= 0) {
/* etc etc */```

5. In C, false is 0, true is 1. So yes, you could add all the conditions and check if that sum is 0 (all three are false), or 3 (all three are true).

Or as laserlight pointer out, you can use the logical operators 'or', 'and', 'not'.

6. Originally Posted by kingliaho
if (condition) OR (condition) OR (condition)

and the 'false' of each of these conditions returns -1
In C the numerical value of false is zero
and the 'true' returns a positive integer?
The numerical value of true is non-zero so a condition may evaluate to -1 or any negative number but it would be true.
It is upto the coder to do the error checking by testing the conditional evaluation and making their code more robust ie
Code:
```if (condition > 0)
/* start here if true */
else
/* if false begin here */```