Greater than

From Microduino Wiki
Revision as of 06:57, 10 August 2016 by Fengfeng (talk) (Created page with "*''' ==, !=, <, >(comparison operators)''' Comparison operators: <pre style="color:green"> if(x == y) { // execute certain statements } //If x is equal t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
  • ==, !=, <, >(comparison operators)

Comparison operators:


 if(x == y)   
{
  // execute certain statements
}      
 //If x is equal to y, execute the statement in the brackets.
 if(x != y)          //If x is not equal to y, execute the statement in the brackets.
 
 if(x <  y)        //If x is less than y, execute the statement in the brackets.

 if(x >  y)         //If x is larger than y, execute the statement in the brackets.


 if(x <= y)        //If x is less than or equal to y, execute the statement in the brackets.

 if(x >= y)       //If x is larger than or equal to y, execute the statement in the brackets.

  • Note:

When using the assignment operator(for example if (x = 10)), single “=” is the assignment operator, which is to set the value of x as 10(put 10 into the internal storage of variable x).

This is because C calculates according to the following rule if (x=10):assign 10 to x(as long as it is the assignment statement of non-zero value, the result is always true),so the current value of x is 10. And at the same time, the test expression value is 10, and the value is always true, because non-zero values are always true.


[Return to Arduino Syntax Manual]