SlideShare uma empresa Scribd logo
1 de 21
Algorithms and programming
basics
• Boolean operations
• Control structures
• if..else
• switch..case
Binary logic
• bool variable
• 1/0 – variable keep one of two variants
• It interpreter like true or false
• Binary logic is a statements, that gives one
result – true or false (0 or 1)
• 14>2 = 1(true)
• Example:
• int x = 12;
• x == 12
• Output: 1
Equality and relational operators
equality operator
or
relational operator
C++ equality
or rela tional
Operator
Example
of C++
condition
Meaning of
C++ condition
Relational operators
> > x > y x is greater than y
< < x < y x is less than y
 >= x >= y xis greater than or equal to y
 <= x <= y x is less than or equal to y
Equality operators
= == x == y x is equal to y
 != x != y x is not equal to y
Logical Operators
• Used as conditions in loops, if statements
• && (logical AND)
▫ true if both conditions are true
if ( gender == 1 && age >= 65 )
++seniorFemales;
• || (logical OR)
▫ true if either of condition is true
if ( semesterAverage>= 90|| finalExam >= 90 )
cout << "Student grade is A" << endl;
Logical Operators
• ! (logical NOT, logical negation)
▫ Returns true when its condition is false, & vice
versa
if ( !( grade == sentinelValue ) )
cout << "The next grade is " << grade << endl;
Alternative:
if ( grade != sentinelValue )
cout << "The next grade is " << grade << endl;
Control Structures
• Sequential execution
▫ Statements executed in order
• Transfer of control
▫ Next statement executed not next one in
sequence
• 3 control structures
▫ Sequence structure
 Programs executed sequentially by default
▫ Selection structures
 if, if/else, switch
▫ Repetition structures
 while, do/while, for
if Selection Structure
• Selection structure
▫ Choose among alternative courses of action
▫ Pseudocode example:
▫ If the condition is true
 Print statement executed, program continues to
next statement
▫ If the condition is false
 Print statement ignored, program continues
▫ Indenting makes programs easier to read
 C++ ignores whitespace characters (tabs, spaces,
etc.)
if Selection Structure
•if (logical statement)
•Action1;
•Else
•Action2;
if Selection Structure
• Translation into C++
If student’s grade is greater than or equal to 60
Print “Passed”
if ( grade >= 60 )
cout << "Passed";
• Diamond symbol (decision symbol)
▫ Indicates decision is to be made
▫ Contains an expression that can be true or false
 Test condition, follow path
• if structure
▫ Single-entry/single-exit
if/else structure
• “if” structure
▫ Make decision based on truth or falsity of
condition
▫ If condition met – body is executed, else - bodyis
not executed
▫ If there is an “else” structure
 Then if condition is false
the body of “else” structure
is executed
if/else structure
if(x > 10){
cout << "x is more than ten";
y = x * 2;
}
else
cout << "x is smaller";
• If there is more than one statements or expressions
in “if/else” structure use curly brackets { }
if/else Selection Structure
• if
▫ Performs action if condition true
• if/else
▫ Different actions if conditions true or false
• Pseudocode
if student’s grade is greater than or equal to 60
print “Passed”
else
print “Failed”
• C++ code
if ( grade >= 50 )
cout << "Passed";
else
cout << "Failed";
if/else Selection Structure
• Ternary conditional operator (?:)
▫ Three arguments (condition, value if true,
value if false)
• Code could be written:
cout << ( grade >= 60 ? “Passed” : “Failed” );
true
false
print “Failed” print “Passed”
grade >= 60
Condition Value if true Value if false
if/else Selection Structure
• Nested if/else structures
▫ One inside another, test for multiple cases
▫ Once condition met, other statements skipped
if student’s grade is greater than or equal to 90
Print “A”
else
if student’s grade is greater than or equal to 80
Print “B”
else
if student’s grade is greater than or equal to 70
Print “C”
else
if student’s grade is greater than or equal to 60
Print “D”
else
Print “F”
if/else Selection Structure
if/else Selection Structure
• if (logical statement){
• Action1;
• Action2;
• Action3;
• }
• Else
• Action4;
• if (logical statement){
• Action1;
• Action2;
• }
• Else{
• Action3;
• Action4;
• }
if/else Selection Structure
• Compound statement
▫ Set of statements within a pair of braces
if ( grade >= 50 )
cout << "Passed.n";
else {
cout << "Failed.n";
cout << "You must take this course again.n";
}
▫ Without braces,
cout << "You must take this course again.n";
always executed
• Block
▫ Set of statements within braces
Switch structure
• Used for testing variable for multiple values
• For each value the case keyword is used
• If no cases matched then optional default is used
• switch(){
▫ case value1: statements; break;
▫ case value2: statements; break;
▫ ……
▫ default: statements; break;
• }
Switch and nested if else
Switch structure is the same as nested if/else structure
that uses only equality comparison
Switch diagram
52
Thanks for
your
attention!

Mais conteúdo relacionado

Semelhante a Control Structures, If..else, switch..case.pptx

Control structures in C++ Programming Language
Control structures in C++ Programming LanguageControl structures in C++ Programming Language
Control structures in C++ Programming LanguageAhmad Idrees
 
Pi j1.3 operators
Pi j1.3 operatorsPi j1.3 operators
Pi j1.3 operatorsmcollison
 
Selection Control Structures
Selection Control StructuresSelection Control Structures
Selection Control StructuresPRN USM
 
Metode Perancangan Program #2 Selection and Repetition Control Structure-ITSB...
Metode Perancangan Program #2 Selection and Repetition Control Structure-ITSB...Metode Perancangan Program #2 Selection and Repetition Control Structure-ITSB...
Metode Perancangan Program #2 Selection and Repetition Control Structure-ITSB...ronistgdr
 
Control Structures.pptx
Control Structures.pptxControl Structures.pptx
Control Structures.pptxssuserfb3c3e
 
Control statements anil
Control statements anilControl statements anil
Control statements anilAnil Dutt
 
Lecture#3 Algorithms and computing
Lecture#3 Algorithms and computingLecture#3 Algorithms and computing
Lecture#3 Algorithms and computingNUST Stuff
 
CSC111-Chap_03.pdf
CSC111-Chap_03.pdfCSC111-Chap_03.pdf
CSC111-Chap_03.pdf2b75fd3051
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Muhammad Tahir Bashir
 
Decision Control Structure If & Else
Decision Control Structure If & ElseDecision Control Structure If & Else
Decision Control Structure If & ElseAbdullah Bhojani
 
Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1Blue Elephant Consulting
 
Object oriented programming16 boolean expressions and selection statements
Object oriented programming16 boolean expressions and selection statementsObject oriented programming16 boolean expressions and selection statements
Object oriented programming16 boolean expressions and selection statementsVaibhav Khanna
 

Semelhante a Control Structures, If..else, switch..case.pptx (20)

Control structures in C++ Programming Language
Control structures in C++ Programming LanguageControl structures in C++ Programming Language
Control structures in C++ Programming Language
 
Pi j1.3 operators
Pi j1.3 operatorsPi j1.3 operators
Pi j1.3 operators
 
Selection Control Structures
Selection Control StructuresSelection Control Structures
Selection Control Structures
 
Selection
SelectionSelection
Selection
 
Control structures in C
Control structures in CControl structures in C
Control structures in C
 
Metode Perancangan Program #2 Selection and Repetition Control Structure-ITSB...
Metode Perancangan Program #2 Selection and Repetition Control Structure-ITSB...Metode Perancangan Program #2 Selection and Repetition Control Structure-ITSB...
Metode Perancangan Program #2 Selection and Repetition Control Structure-ITSB...
 
Control Structures.pptx
Control Structures.pptxControl Structures.pptx
Control Structures.pptx
 
Ch3.1
Ch3.1Ch3.1
Ch3.1
 
Using decision statements
Using decision statementsUsing decision statements
Using decision statements
 
Java Programmin: Selections
Java Programmin: SelectionsJava Programmin: Selections
Java Programmin: Selections
 
Control statements anil
Control statements anilControl statements anil
Control statements anil
 
Lecture#3 Algorithms and computing
Lecture#3 Algorithms and computingLecture#3 Algorithms and computing
Lecture#3 Algorithms and computing
 
CSC111-Chap_03.pdf
CSC111-Chap_03.pdfCSC111-Chap_03.pdf
CSC111-Chap_03.pdf
 
Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)Understand Decision structures in c++ (cplusplus)
Understand Decision structures in c++ (cplusplus)
 
C++ IF STATMENT AND ITS TYPE
C++ IF STATMENT AND ITS TYPEC++ IF STATMENT AND ITS TYPE
C++ IF STATMENT AND ITS TYPE
 
Decision Control Structure If & Else
Decision Control Structure If & ElseDecision Control Structure If & Else
Decision Control Structure If & Else
 
Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1Intro To C++ - Class 09 - Control Statements: Part 1
Intro To C++ - Class 09 - Control Statements: Part 1
 
conditional_statement.pdf
conditional_statement.pdfconditional_statement.pdf
conditional_statement.pdf
 
Object oriented programming16 boolean expressions and selection statements
Object oriented programming16 boolean expressions and selection statementsObject oriented programming16 boolean expressions and selection statements
Object oriented programming16 boolean expressions and selection statements
 
Chapter 1 nested control structures
Chapter 1 nested control structuresChapter 1 nested control structures
Chapter 1 nested control structures
 

Último

Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfFIDO Alliance
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeCzechDreamin
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftshyamraj55
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsUXDXConf
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKUXDXConf
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityScyllaDB
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGDSC PJATK
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...CzechDreamin
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastUXDXConf
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfFIDO Alliance
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessUXDXConf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 

Último (20)

Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdfHow Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
How Red Hat Uses FDO in Device Lifecycle _ Costin and Vitaliy at Red Hat.pdf
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi IbrahimzadeFree and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
Free and Effective: Making Flows Publicly Accessible, Yumi Ibrahimzade
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Optimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through ObservabilityOptimizing NoSQL Performance Through Observability
Optimizing NoSQL Performance Through Observability
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
Syngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdfSyngulon - Selection technology May 2024.pdf
Syngulon - Selection technology May 2024.pdf
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
Designing for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at ComcastDesigning for Hardware Accessibility at Comcast
Designing for Hardware Accessibility at Comcast
 
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdfLinux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
Linux Foundation Edge _ Overview of FDO Software Components _ Randy at Intel.pdf
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 

Control Structures, If..else, switch..case.pptx

  • 1. Algorithms and programming basics • Boolean operations • Control structures • if..else • switch..case
  • 2. Binary logic • bool variable • 1/0 – variable keep one of two variants • It interpreter like true or false • Binary logic is a statements, that gives one result – true or false (0 or 1) • 14>2 = 1(true) • Example: • int x = 12; • x == 12 • Output: 1
  • 3. Equality and relational operators equality operator or relational operator C++ equality or rela tional Operator Example of C++ condition Meaning of C++ condition Relational operators > > x > y x is greater than y < < x < y x is less than y  >= x >= y xis greater than or equal to y  <= x <= y x is less than or equal to y Equality operators = == x == y x is equal to y  != x != y x is not equal to y
  • 4. Logical Operators • Used as conditions in loops, if statements • && (logical AND) ▫ true if both conditions are true if ( gender == 1 && age >= 65 ) ++seniorFemales; • || (logical OR) ▫ true if either of condition is true if ( semesterAverage>= 90|| finalExam >= 90 ) cout << "Student grade is A" << endl;
  • 5. Logical Operators • ! (logical NOT, logical negation) ▫ Returns true when its condition is false, & vice versa if ( !( grade == sentinelValue ) ) cout << "The next grade is " << grade << endl; Alternative: if ( grade != sentinelValue ) cout << "The next grade is " << grade << endl;
  • 6. Control Structures • Sequential execution ▫ Statements executed in order • Transfer of control ▫ Next statement executed not next one in sequence • 3 control structures ▫ Sequence structure  Programs executed sequentially by default ▫ Selection structures  if, if/else, switch ▫ Repetition structures  while, do/while, for
  • 7. if Selection Structure • Selection structure ▫ Choose among alternative courses of action ▫ Pseudocode example: ▫ If the condition is true  Print statement executed, program continues to next statement ▫ If the condition is false  Print statement ignored, program continues ▫ Indenting makes programs easier to read  C++ ignores whitespace characters (tabs, spaces, etc.)
  • 8. if Selection Structure •if (logical statement) •Action1; •Else •Action2;
  • 9. if Selection Structure • Translation into C++ If student’s grade is greater than or equal to 60 Print “Passed” if ( grade >= 60 ) cout << "Passed"; • Diamond symbol (decision symbol) ▫ Indicates decision is to be made ▫ Contains an expression that can be true or false  Test condition, follow path • if structure ▫ Single-entry/single-exit
  • 10. if/else structure • “if” structure ▫ Make decision based on truth or falsity of condition ▫ If condition met – body is executed, else - bodyis not executed ▫ If there is an “else” structure  Then if condition is false the body of “else” structure is executed
  • 11. if/else structure if(x > 10){ cout << "x is more than ten"; y = x * 2; } else cout << "x is smaller"; • If there is more than one statements or expressions in “if/else” structure use curly brackets { }
  • 12. if/else Selection Structure • if ▫ Performs action if condition true • if/else ▫ Different actions if conditions true or false • Pseudocode if student’s grade is greater than or equal to 60 print “Passed” else print “Failed” • C++ code if ( grade >= 50 ) cout << "Passed"; else cout << "Failed";
  • 13. if/else Selection Structure • Ternary conditional operator (?:) ▫ Three arguments (condition, value if true, value if false) • Code could be written: cout << ( grade >= 60 ? “Passed” : “Failed” ); true false print “Failed” print “Passed” grade >= 60 Condition Value if true Value if false
  • 14. if/else Selection Structure • Nested if/else structures ▫ One inside another, test for multiple cases ▫ Once condition met, other statements skipped if student’s grade is greater than or equal to 90 Print “A” else if student’s grade is greater than or equal to 80 Print “B” else if student’s grade is greater than or equal to 70 Print “C” else if student’s grade is greater than or equal to 60 Print “D” else Print “F”
  • 16. if/else Selection Structure • if (logical statement){ • Action1; • Action2; • Action3; • } • Else • Action4; • if (logical statement){ • Action1; • Action2; • } • Else{ • Action3; • Action4; • }
  • 17. if/else Selection Structure • Compound statement ▫ Set of statements within a pair of braces if ( grade >= 50 ) cout << "Passed.n"; else { cout << "Failed.n"; cout << "You must take this course again.n"; } ▫ Without braces, cout << "You must take this course again.n"; always executed • Block ▫ Set of statements within braces
  • 18. Switch structure • Used for testing variable for multiple values • For each value the case keyword is used • If no cases matched then optional default is used • switch(){ ▫ case value1: statements; break; ▫ case value2: statements; break; ▫ …… ▫ default: statements; break; • }
  • 19. Switch and nested if else Switch structure is the same as nested if/else structure that uses only equality comparison