Decision making structures require that the programmer specify one or
more conditions to be evaluated or tested by the program. It should be
along with a statement or statements to be executed if the condition is
determined to be true, and optionally, other statements to be executed
if the condition is determined to be false.
Following is the general form of a typical decision making structure found in most of the programming languages −
Control Statements are elements in Source Code that control the flow of program execution.
They are −
Form 2
Following is the general form of a typical decision making structure found in most of the programming languages −
Control Statements are elements in Source Code that control the flow of program execution.
They are −
1-Arduino - If statement
It takes an expression in parenthesis and a statement or block of statements. If the expression is true then the statement or block of statements gets executed otherwise these statements are skipped.
Different forms of if statement
Form 1if (expression) statement;You can use the if statement without braces { } if you have one statement.
Form 2
if (expression) { Block of statements; }
if Statement – Execution Sequence
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++; /* check the boolean condition */ If ( ( A < B ) && ( B != 0 ))
/* if condition is true then execute the following statement*/
{ A += B; B--; } }
0 comments:
Post a Comment