3. Conditional Statements
• Conditional Statements
• Conditional statements are used to perform different
actions based on different conditions
• If statement
• Use the if statement if you want to execute a set of
code when a condition is true
• Syntax
• if (condition) {
statements_1
} else {
statements_2
}
4. • if...else statement
• use this statement to execute some code if the
condition is true and another code if the
condition is false
• Syntax
• if (condition)
• { code to be executed if condition is true }
• else
• { code to be executed if condition is false }
5. • Nested if....else statement
• use this statement to select one of many blocks of code to
be executed
• syntax
• if (condition_1)
statement_1
[else if (condition_2)
statement_2]
...
[else if (condition_n_1)
statement_n_1]
[else
statement_n]
6. •
•
•
•
switch statement
use this statement to select one of many blocks of code to be executed
syntax
switch (expression) {
case label_1:
statements_1
[break;]
case label_2:
statements_2
[break;]
...
default:
statements_n
[break;]
}
7. If this presentation helped you, please visit our
page facebook.com/baabtra and like it.
Thanks in advance.
www.baabtra.com | www.massbaab.com |www.baabte.com
8. Contact Us
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550