````

Arduino - If …else statement

An if statement can be followed by an optional else statement, which executes when the expression is false.

if … else Statement Syntax

if (expression) {
   Block of statements;
}
else {
   Block of statements;
}

if…else Statement – Execution Sequence

If Else Statement

Example

/* Global variable definition */
int A = 5 ;
int B = 9 ;

Void setup () {

}

Void loop () {
   /* check the boolean condition */
   if (A > B) 
 /* if condition is true then execute the following statement*/  
{
      A++;
   }else {
      B -= A;
   }
}

0 comments:

Post a Comment

 
Powered by Blogger