SlideShare a Scribd company logo
In cases when you need to test for multiple conditions, writing if else statements for each condition might
not be the best solution.
The switch statement is used to perform different actions based on different conditions.
Syntax
The switch expression is evaluated once. The value of the expression is compared with
the values of each case. If there is a match, the associated block of code is executed.
Switch
switch (expression) {
case n1:
statements
break;
case n2:
statements
break;
default:
statements
}

More Related Content

PPTX
Switch
sidneyodingo
 
PPTX
html 5
sidneyodingo
 
PPTX
html 5
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
Switch
sidneyodingo
 
html 5
sidneyodingo
 
html 5
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 

More from sidneyodingo (20)

PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Welcome to css!
sidneyodingo
 
PPTX
Object properties
sidneyodingo
 
PPTX
Objects
sidneyodingo
 
PPTX
Multiple parameters
sidneyodingo
 
PPTX
Functions parameters
sidneyodingo
 
PPTX
Calling functions
sidneyodingo
 
PPTX
Break
sidneyodingo
 
PPTX
Do while loop
sidneyodingo
 
PPTX
Do while
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Welcome to css!
sidneyodingo
 
Object properties
sidneyodingo
 
Objects
sidneyodingo
 
Multiple parameters
sidneyodingo
 
Functions parameters
sidneyodingo
 
Calling functions
sidneyodingo
 
Do while loop
sidneyodingo
 
Do while
sidneyodingo
 
Ad

Recently uploaded (20)

PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PDF
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PDF
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PPTX
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PPTX
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Basics and rules of probability with real-life uses
ravatkaran694
 
2.Reshaping-Indias-Political-Map.ppt/pdf/8th class social science Exploring S...
Sandeep Swamy
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
CARE OF UNCONSCIOUS PATIENTS .pptx
AneetaSharma15
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
RA 12028_ARAL_Orientation_Day-2-Sessions_v2.pdf
Seven De Los Reyes
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
TEF & EA Bsc Nursing 5th sem.....BBBpptx
AneetaSharma15
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
Artificial-Intelligence-in-Drug-Discovery by R D Jawarkar.pptx
Rahul Jawarkar
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
Ad

Switch

  • 1. In cases when you need to test for multiple conditions, writing if else statements for each condition might not be the best solution. The switch statement is used to perform different actions based on different conditions. Syntax The switch expression is evaluated once. The value of the expression is compared with the values of each case. If there is a match, the associated block of code is executed. Switch switch (expression) { case n1: statements break; case n2: statements break; default: statements }