Relational operators are operators like '==' and '&&'. You can't assign a variable to a relational operator, but you use relational operators and variables in an expression which evaluates to true or false. And the result of this evaluation can be assigned to a variable.
Example:
result = a && b;
If a is true and b is true, then result gets the value true. If a is false or b is false or a is false and b is false, then result is false.
Note that it true is not always 1 and false is not always 0!!
>Why wouldn't i just assign a 1 or 0 to the variable?
Relational operators are used to make decisions. They are for example used in if-constructions:
Code:
if (result == true)
{
/* do this */
}
else
{
/* do this */
}
>val= (val==14) ? 1 : val; /*If val is 14, reset to 1 */
This is a ternary operator.
result = (a == b) ? 1 : 0;
First the value of (a == b) is calculated, in other words, it is checked if a and b are equal, this can be true or false. If a and b are equal, then result gets the value 1, else result gets the value 0.
You can just assign a 1 or 0 to the variable, but then you would still need the if-construction. Just as shaik786 explained.