
- Arduino Tutorial
- Arduino - Home
- Arduino - Overview
- Arduino - Board Description
- Arduino - Installation
- Arduino - Program Structure
- Arduino - Data Types
- Arduino - Variables & Constants
- Arduino - Operators
- Arduino - Control Statements
- Arduino - Loops
- Arduino - Functions
- Arduino - Strings
- Arduino - String Object
- Arduino - Time
- Arduino - Arrays
- Arduino Function Libraries
- Arduino - I/O Functions
- Arduino - Advanced I/O Function
- Arduino - Character Functions
- Arduino - Math Library
- Arduino - Trigonometric Functions
- Arduino Advanced
- Arduino - Due & Zero
- Arduino - Pulse Width Modulation
- Arduino - Random Numbers
- Arduino - Interrupts
- Arduino - Communication
- Arduino - Inter Integrated Circuit
- Arduino - Serial Peripheral Interface
- Arduino Projects
- Arduino - Blinking LED
- Arduino - Fading LED
- Arduino - Reading Analog Voltage
- Arduino - LED Bar Graph
- Arduino - Keyboard Logout
- Arduino - Keyboard Message
- Arduino - Mouse Button Control
- Arduino - Keyboard Serial
- Arduino Sensors
- Arduino - Humidity Sensor
- Arduino - Temperature Sensor
- Arduino - Water Detector / Sensor
- Arduino - PIR Sensor
- Arduino - Ultrasonic Sensor
- Arduino - Connecting Switch
- Motor Control
- Arduino - DC Motor
- Arduino - Servo Motor
- Arduino - Stepper Motor
- Arduino And Sound
- Arduino - Tone Library
- Arduino - Wireless Communication
- Arduino - Network Communication
- Arduino Useful Resources
- Arduino - Quick Guide
- Arduino - Useful Resources
- Arduino - Discussion
Arduino - Ifelse if else statement
The if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement.
When using if...else ifelse statements, keep in mind −
An if can have zero or one else statement and it must come after any else if's.
An if can have zero to many else if statements and they must come before the else.
Once an else if succeeds, none of the remaining else if or else statements will be tested.
if else if else Statements Syntax
if (expression_1) { Block of statements; } else if(expression_2) { Block of statements; } . . . else { Block of statements; }
if else if else Statement Execution Sequence

Example
/* Global variable definition */ int A = 5 ; int B = 9 ; int c = 15; 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 */ else if ((A == B )||( B < c) ) /* if condition is true then execute the following statement*/ { C = B* A; }else c++; }
arduino_control_statements.htm
Advertisements