SlideShare une entreprise Scribd logo
1  sur  23
Chapter 3 CONTROL STRUCTURES: SELECTION
Topic ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Structured Programming ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sequence Structure Example ,[object Object],[object Object],[object Object],[object Object]
Sequence Structure Example ,[object Object]
Sequence Structure Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
SELECTION STRUCTURES ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
if Selection ,[object Object],[object Object],Syntax: if  (condition) statement ; if  selection Flowchart
if Selection Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
if Selection Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
if…else Selection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
if…else Selection Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
if…else Selection Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
if…else Selection Examples ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Conditional Operator (?:) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Switch Selection ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The  switch  statement ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Transformation from  switch  to  if…else  statement   if (x == ‘a’)   printf("x is a"); else if (x == ‘b’)   printf("x is b"); else   printf("value of x unknown"); switch (x)  {   case ‘a’:   printf("x is a");   break;   case ‘b’:   printf("x is b");   break;   default:   printf("value of x unknown"); } if…else  statement switch  statement
TUTORIAL
Exercise ,[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software development
Hattori Sidek
 
Control Structures
Control StructuresControl Structures
Control Structures
Ghaffar Khan
 
04 control structures 1
04 control structures 104 control structures 1
04 control structures 1
Jomel Penalba
 

Tendances (20)

Ch1 principles of software development
Ch1 principles of software developmentCh1 principles of software development
Ch1 principles of software development
 
CONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGECONDITIONAL STATEMENT IN C LANGUAGE
CONDITIONAL STATEMENT IN C LANGUAGE
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
Control structure of c language
Control structure of c languageControl structure of c language
Control structure of c language
 
Control Flow Statements
Control Flow Statements Control Flow Statements
Control Flow Statements
 
C decision making and looping.
C decision making and looping.C decision making and looping.
C decision making and looping.
 
Control structures in C
Control structures in CControl structures in C
Control structures in C
 
Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
Control Structures
Control StructuresControl Structures
Control Structures
 
Unit 5. Control Statement
Unit 5. Control StatementUnit 5. Control Statement
Unit 5. Control Statement
 
Decision statements in c language
Decision statements in c languageDecision statements in c language
Decision statements in c language
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Control and conditional statements
Control and conditional statementsControl and conditional statements
Control and conditional statements
 
COM1407: Program Control Structures – Decision Making & Branching
COM1407: Program Control Structures – Decision Making & BranchingCOM1407: Program Control Structures – Decision Making & Branching
COM1407: Program Control Structures – Decision Making & Branching
 
Control Structures: Part 1
Control Structures: Part 1Control Structures: Part 1
Control Structures: Part 1
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
Decision making statements in C programming
Decision making statements in C programmingDecision making statements in C programming
Decision making statements in C programming
 
operators and control statements in c language
operators and control statements in c languageoperators and control statements in c language
operators and control statements in c language
 
04 control structures 1
04 control structures 104 control structures 1
04 control structures 1
 

En vedette (20)

Ch6 pointers (latest)
Ch6 pointers (latest)Ch6 pointers (latest)
Ch6 pointers (latest)
 
Ch8 file processing
Ch8 file processingCh8 file processing
Ch8 file processing
 
9 lan
9 lan9 lan
9 lan
 
Ch4 functions
Ch4 functionsCh4 functions
Ch4 functions
 
10 high speedla-ns
10 high speedla-ns10 high speedla-ns
10 high speedla-ns
 
Ch7 structures
Ch7 structuresCh7 structures
Ch7 structures
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
 
13 atm
13 atm13 atm
13 atm
 
Ch5 array nota
Ch5 array notaCh5 array nota
Ch5 array nota
 
6 data linkcontrol
6  data linkcontrol6  data linkcontrol
6 data linkcontrol
 
8 spread spectrum
8 spread spectrum8 spread spectrum
8 spread spectrum
 
5 digital datacomm
5 digital datacomm5 digital datacomm
5 digital datacomm
 
12 wireless la-ns
12 wireless la-ns12 wireless la-ns
12 wireless la-ns
 
AM Receivers
AM ReceiversAM Receivers
AM Receivers
 
11 circuit-packet
11 circuit-packet11 circuit-packet
11 circuit-packet
 
Types of AM Receiver
Types of AM Receiver Types of AM Receiver
Types of AM Receiver
 
Chapter 3 am receivers
Chapter 3 am receiversChapter 3 am receivers
Chapter 3 am receivers
 
4 signal encodingtechniques
4 signal encodingtechniques4 signal encodingtechniques
4 signal encodingtechniques
 
7 multiplexing
7 multiplexing7 multiplexing
7 multiplexing
 
Chapter 2 amplitude_modulation
Chapter 2 amplitude_modulationChapter 2 amplitude_modulation
Chapter 2 amplitude_modulation
 

Similaire à Ch3 selection

CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
Sanjjaayyy
 
Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2
alish sha
 
Branching statements
Branching statementsBranching statements
Branching statements
ArunMK17
 
Input output functions
Input output functionsInput output functions
Input output functions
hyderali123
 
Presentation.mehr
Presentation.mehrPresentation.mehr
Presentation.mehr
imhammadali
 
Falcon初印象
Falcon初印象Falcon初印象
Falcon初印象
勇浩 赖
 

Similaire à Ch3 selection (20)

C programming Control Structure.pptx
C programming Control Structure.pptxC programming Control Structure.pptx
C programming Control Structure.pptx
 
CONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.pptCONTROLSTRUCTURES.ppt
CONTROLSTRUCTURES.ppt
 
CONTROL FLOW in C.pptx
CONTROL FLOW in C.pptxCONTROL FLOW in C.pptx
CONTROL FLOW in C.pptx
 
Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2Dti2143 chap 4 control statement part 2
Dti2143 chap 4 control statement part 2
 
Loop's definition and practical code in C programming
Loop's definition and  practical code in C programming Loop's definition and  practical code in C programming
Loop's definition and practical code in C programming
 
C Unit-2.ppt
C Unit-2.pptC Unit-2.ppt
C Unit-2.ppt
 
Branching statements
Branching statementsBranching statements
Branching statements
 
4 operators, expressions & statements
4  operators, expressions & statements4  operators, expressions & statements
4 operators, expressions & statements
 
Input output functions
Input output functionsInput output functions
Input output functions
 
Presentation1
Presentation1Presentation1
Presentation1
 
Unit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in CUnit ii chapter 2 Decision making and Branching in C
Unit ii chapter 2 Decision making and Branching in C
 
2 data and c
2 data and c2 data and c
2 data and c
 
C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0C++11 - A Change in Style - v2.0
C++11 - A Change in Style - v2.0
 
unit 2-Control Structures.pptx
unit 2-Control Structures.pptxunit 2-Control Structures.pptx
unit 2-Control Structures.pptx
 
3. chapter ii
3. chapter ii3. chapter ii
3. chapter ii
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
 
Presentation.mehr
Presentation.mehrPresentation.mehr
Presentation.mehr
 
Falcon初印象
Falcon初印象Falcon初印象
Falcon初印象
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 

Plus de Hattori Sidek

Plus de Hattori Sidek (10)

Chapter 4 frequency modulation
Chapter 4 frequency modulationChapter 4 frequency modulation
Chapter 4 frequency modulation
 
3. transmission media
3. transmission media3. transmission media
3. transmission media
 
2[1].1 data transmission
2[1].1 data transmission2[1].1 data transmission
2[1].1 data transmission
 
14 congestionin datanetworks
14 congestionin datanetworks14 congestionin datanetworks
14 congestionin datanetworks
 
01 pengenalan
01 pengenalan01 pengenalan
01 pengenalan
 
01 berkenalan
01 berkenalan01 berkenalan
01 berkenalan
 
Comm introduction
Comm introductionComm introduction
Comm introduction
 
Chapter5 dek3133
Chapter5 dek3133Chapter5 dek3133
Chapter5 dek3133
 
Chapter 6 edit
Chapter 6 editChapter 6 edit
Chapter 6 edit
 
Chapter 6 dc motor speed control
Chapter 6 dc motor speed controlChapter 6 dc motor speed control
Chapter 6 dc motor speed control
 

Dernier

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Dernier (20)

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 

Ch3 selection

  • 1. Chapter 3 CONTROL STRUCTURES: SELECTION
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. Transformation from switch to if…else statement if (x == ‘a’) printf("x is a"); else if (x == ‘b’) printf("x is b"); else printf("value of x unknown"); switch (x) { case ‘a’: printf("x is a"); break; case ‘b’: printf("x is b"); break; default: printf("value of x unknown"); } if…else statement switch statement
  • 23.