SlideShare a Scribd company logo
1 of 16
C H AP T E R 6
B R AN C H I N G
PROG0101
FUNDAMENTALS OF PROGRAMMING
Chapter 5
Operators
PROG0101
FUNDAMENTALS OF PROGRAMMING
CHAPTER 4
VARIABLES AND DATA
TYPES
PROG0101
FUNDAMENTALS OF PROGRAMMING
CHAPTER 3
ALGORITHMS
PROG0101
FUNDAMENTALS OF PROGRAMMING
C H A P T E R 1
O V E R V I E W O F C O M P U T E R S A N D L O G I C
PROG0101
FUNDAMENTALS OF
PROGRAMMING
PROG0101
FUNDAMENTALS OF PROGRAMMING
CHAPTER 6
BRANCHING STATEMENTS
2
BRANCHING STATEMENTS
Branching Statements
 A program consists of a number of statements which are
usually executed in sequence.
 Programs can be much more powerful if we can control the
order in which statements are run.
 The Branching Statements or Control Statements let the
program makes a decision about what to do next.
3
BRANCHING STATEMENTS
Branching Statements
 Examples of Branching Statements in programming:
 IF Statement
 Switch Statement
4
IF STATEMENT
 The IF Statement is a powerful decision making statement
and is used to control the flow of execution of statements.
 It is basically a two-way decision statement and is used in
conjunction with an expression.
5
IF STATEMENT
 It allows the computer to evaluate the expression first and
then, depending on whether the value of the expression
(relation or condition) is ' true ' (non-zero) or ' false ' (zero),
it transfers the control to a particular statement.
 This point of program has two paths to follow, one for the
true condition and the other for the false condition.
 The if statement may be implemented in different forms
depending on the complexity of the conditions to be tested.
6
IF STATEMENT
IF Statement
 Two types of IF Statement:
 Simple IF Statement
 IF-ELSE Statement
7
IF STATEMENT
Simple IF Statement
 The statement-block may be a single statement or a group
of statements.
 If the test expression is true, the statement-block will be
executed; otherwise the statement-block will be skipped
and the execution will jump to statement-x.
 Remember, when the condition is true both the statement-
block and the statement-x are executed in sequence.
8
IF STATEMENT
Simple IF Statement
9
IF STATEMENT
IF-ELSE Statement
 The if....else statement is an extension of the simple if
statement.
 If the test expression is true , then the true-block
statement(s), immediately following the if statement are
executed; otherwise the false-block statement(s) are
executed.
 In either case, either true-block or false-block will be
executed, not both.
10
IF STATEMENT
IF-ELSE Statement
11
IF STATEMENT
Example 1
The flow chart shows a
program which ask a user to
enter a number, and then
compare the number given
either it is bigger or smaller
than 5.
12
IF STATEMENT
Example 2
The flow chart shows a program to check whether the student
“Passed” or “Failed”.
13
SWITCH STATEMENT
 In computer programming, a Switch Statement (also
known as Case Statement) is a type of control statement
that exists in most modern imperative programming
languages.
 This is another form of the multi way decision.
 A switch statement is a selection statement that lets you
transfer control to different statements within the switch
body depending on the value of the switch expression.
14
SWITCH STATEMENT
 If the value of the switch expression equals the value of
one of the case expressions, the statements following that
case expression are processed.
 If not, the default label statements, if any, are processed.
15
SWITCH STATEMENT
Example 1
16
SWITCH STATEMENT
Example 2

More Related Content

What's hot

Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrolsteach4uin
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statementSwitch statement, break statement, go to statement
Switch statement, break statement, go to statementRaj Parekh
 
Switch Case in C Programming
Switch Case in C ProgrammingSwitch Case in C Programming
Switch Case in C ProgrammingSonya Akter Rupa
 
10. switch case
10. switch case10. switch case
10. switch caseWay2itech
 
If and select statement
If and select statementIf and select statement
If and select statementRahul Sharma
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual BasicTushar Jain
 
Exception
ExceptionException
Exceptionwork
 
Vb decision making statements
Vb decision making statementsVb decision making statements
Vb decision making statementspragya ratan
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement_jenica
 
Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1Techglyphs
 
C statements
C statementsC statements
C statementsAhsann111
 
[ITP - Lecture 08] Decision Control Structures (If Statement)
[ITP - Lecture 08] Decision Control Structures (If Statement)[ITP - Lecture 08] Decision Control Structures (If Statement)
[ITP - Lecture 08] Decision Control Structures (If Statement)Muhammad Hammad Waseem
 
Modula 2 tutorial - 005 - statements
Modula 2 tutorial - 005 - statementsModula 2 tutorial - 005 - statements
Modula 2 tutorial - 005 - statementsJulian Miglio
 

What's hot (20)

Cprogrammingprogramcontrols
CprogrammingprogramcontrolsCprogrammingprogramcontrols
Cprogrammingprogramcontrols
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
Switch statement, break statement, go to statement
Switch statement, break statement, go to statementSwitch statement, break statement, go to statement
Switch statement, break statement, go to statement
 
Switch Case in C Programming
Switch Case in C ProgrammingSwitch Case in C Programming
Switch Case in C Programming
 
10. switch case
10. switch case10. switch case
10. switch case
 
Tut8 model selection
Tut8 model selectionTut8 model selection
Tut8 model selection
 
Final requirement
Final requirementFinal requirement
Final requirement
 
If and select statement
If and select statementIf and select statement
If and select statement
 
Branching in C
Branching in CBranching in C
Branching in C
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual Basic
 
Exception
ExceptionException
Exception
 
Vb decision making statements
Vb decision making statementsVb decision making statements
Vb decision making statements
 
Tut4 multiple regression
Tut4 multiple regressionTut4 multiple regression
Tut4 multiple regression
 
Flow of Control
Flow of ControlFlow of Control
Flow of Control
 
Switch case and looping statement
Switch case and looping statementSwitch case and looping statement
Switch case and looping statement
 
If
IfIf
If
 
Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1Bt0067 c programming and data structures 1
Bt0067 c programming and data structures 1
 
C statements
C statementsC statements
C statements
 
[ITP - Lecture 08] Decision Control Structures (If Statement)
[ITP - Lecture 08] Decision Control Structures (If Statement)[ITP - Lecture 08] Decision Control Structures (If Statement)
[ITP - Lecture 08] Decision Control Structures (If Statement)
 
Modula 2 tutorial - 005 - statements
Modula 2 tutorial - 005 - statementsModula 2 tutorial - 005 - statements
Modula 2 tutorial - 005 - statements
 

Similar to Fundamentals of Programming Chapter 6

Decision making and looping - c programming by YEASIN NEWAJ
Decision making and looping -  c programming by YEASIN NEWAJDecision making and looping -  c programming by YEASIN NEWAJ
Decision making and looping - c programming by YEASIN NEWAJYeasinNewaj
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statementFarshidKhan
 
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlIntroduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlENGWAU TONNY
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C pptMANJUTRIPATHI7
 
Control flow stataements
Control flow stataementsControl flow stataements
Control flow stataementsMitali Chugh
 
IGCSE ICT Chapter 3- Storage devices and media.ppt
IGCSE ICT Chapter 3- Storage devices and media.pptIGCSE ICT Chapter 3- Storage devices and media.ppt
IGCSE ICT Chapter 3- Storage devices and media.pptAakilaliShaikh
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlanDeepak Lakhlan
 
Compter pogramming and utilization
Compter pogramming and utilizationCompter pogramming and utilization
Compter pogramming and utilizationMaulik Sharma
 
Control statements
Control statementsControl statements
Control statementsCutyChhaya
 
C statements.ppt presentation in c language
C statements.ppt presentation in c languageC statements.ppt presentation in c language
C statements.ppt presentation in c languagechintupro9
 
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...jaychoudhary37
 
Python Programming - Control Flow
Python Programming - Control Flow Python Programming - Control Flow
Python Programming - Control Flow Omid AmirGhiasvand
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Shipra Swati
 
Chapter 9 Conditional and Iterative Statements.pptx
Chapter 9 Conditional and Iterative Statements.pptxChapter 9 Conditional and Iterative Statements.pptx
Chapter 9 Conditional and Iterative Statements.pptxXhelalSpahiu
 
Decision making and loop in C#
Decision making and loop in C#Decision making and loop in C#
Decision making and loop in C#Prasanna Kumar SM
 

Similar to Fundamentals of Programming Chapter 6 (20)

Decision making and looping - c programming by YEASIN NEWAJ
Decision making and looping -  c programming by YEASIN NEWAJDecision making and looping -  c programming by YEASIN NEWAJ
Decision making and looping - c programming by YEASIN NEWAJ
 
Cse lecture-6-c control statement
Cse lecture-6-c control statementCse lecture-6-c control statement
Cse lecture-6-c control statement
 
C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)C Constructs (C Statements & Loop)
C Constructs (C Statements & Loop)
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow controlIntroduction to computer programming (C)-CSC1205_Lec5_Flow control
Introduction to computer programming (C)-CSC1205_Lec5_Flow control
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
Ch04
Ch04Ch04
Ch04
 
Control flow stataements
Control flow stataementsControl flow stataements
Control flow stataements
 
IGCSE ICT Chapter 3- Storage devices and media.ppt
IGCSE ICT Chapter 3- Storage devices and media.pptIGCSE ICT Chapter 3- Storage devices and media.ppt
IGCSE ICT Chapter 3- Storage devices and media.ppt
 
Flow of control by deepak lakhlan
Flow of control by deepak lakhlanFlow of control by deepak lakhlan
Flow of control by deepak lakhlan
 
Compter pogramming and utilization
Compter pogramming and utilizationCompter pogramming and utilization
Compter pogramming and utilization
 
Control statements
Control statementsControl statements
Control statements
 
slides03.ppt
slides03.pptslides03.ppt
slides03.ppt
 
C statements.ppt presentation in c language
C statements.ppt presentation in c languageC statements.ppt presentation in c language
C statements.ppt presentation in c language
 
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...
FAL(2022-23)_FRESHERS_CSE1012_ETH_AP2022234000166_Reference_Material_I_15-Nov...
 
Python Programming - Control Flow
Python Programming - Control Flow Python Programming - Control Flow
Python Programming - Control Flow
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
 
Chapter 9 Conditional and Iterative Statements.pptx
Chapter 9 Conditional and Iterative Statements.pptxChapter 9 Conditional and Iterative Statements.pptx
Chapter 9 Conditional and Iterative Statements.pptx
 
Decision making and loop in C#
Decision making and loop in C#Decision making and loop in C#
Decision making and loop in C#
 
Computer programming 2 Lesson 9
Computer programming 2  Lesson 9Computer programming 2  Lesson 9
Computer programming 2 Lesson 9
 

More from Mohd Harris Ahmad Jaal

Web Application Development using PHP Chapter 8
Web Application Development using PHP Chapter 8Web Application Development using PHP Chapter 8
Web Application Development using PHP Chapter 8Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 6
Web Application Development using PHP Chapter 6Web Application Development using PHP Chapter 6
Web Application Development using PHP Chapter 6Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 2
Web Application Development using PHP Chapter 2Web Application Development using PHP Chapter 2
Web Application Development using PHP Chapter 2Mohd Harris Ahmad Jaal
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Mohd Harris Ahmad Jaal
 

More from Mohd Harris Ahmad Jaal (20)

Fundamentals of Programming Chapter 7
Fundamentals of Programming Chapter 7Fundamentals of Programming Chapter 7
Fundamentals of Programming Chapter 7
 
Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4Fundamentals of Programming Chapter 4
Fundamentals of Programming Chapter 4
 
Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3
 
Fundamentals of Programming Chapter 2
Fundamentals of Programming Chapter 2Fundamentals of Programming Chapter 2
Fundamentals of Programming Chapter 2
 
Fundamentals of Programming Chapter 1
Fundamentals of Programming Chapter 1Fundamentals of Programming Chapter 1
Fundamentals of Programming Chapter 1
 
Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5Fundamentals of Programming Chapter 5
Fundamentals of Programming Chapter 5
 
Web Application Development using PHP Chapter 8
Web Application Development using PHP Chapter 8Web Application Development using PHP Chapter 8
Web Application Development using PHP Chapter 8
 
Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7Web Application Development using PHP Chapter 7
Web Application Development using PHP Chapter 7
 
Web Application Development using PHP Chapter 6
Web Application Development using PHP Chapter 6Web Application Development using PHP Chapter 6
Web Application Development using PHP Chapter 6
 
Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5Web Application Development using PHP Chapter 5
Web Application Development using PHP Chapter 5
 
Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4Web Application Development using PHP Chapter 4
Web Application Development using PHP Chapter 4
 
Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3Web Application Development using PHP Chapter 3
Web Application Development using PHP Chapter 3
 
Web Application Development using PHP Chapter 2
Web Application Development using PHP Chapter 2Web Application Development using PHP Chapter 2
Web Application Development using PHP Chapter 2
 
Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1Web Application Development using PHP Chapter 1
Web Application Development using PHP Chapter 1
 
Fundamentals of Computing Chapter 10
Fundamentals of Computing Chapter 10Fundamentals of Computing Chapter 10
Fundamentals of Computing Chapter 10
 
Fundamentals of Computing Chapter 9
Fundamentals of Computing Chapter 9Fundamentals of Computing Chapter 9
Fundamentals of Computing Chapter 9
 
Fundamentals of Computing Chapter 8
Fundamentals of Computing Chapter 8Fundamentals of Computing Chapter 8
Fundamentals of Computing Chapter 8
 
Fundamentals of Computing Chapter 7
Fundamentals of Computing Chapter 7Fundamentals of Computing Chapter 7
Fundamentals of Computing Chapter 7
 
Fundamentals of Computing Chapter 6
Fundamentals of Computing Chapter 6Fundamentals of Computing Chapter 6
Fundamentals of Computing Chapter 6
 
Fundamentals of Computing Chapter 5
Fundamentals of Computing Chapter 5Fundamentals of Computing Chapter 5
Fundamentals of Computing Chapter 5
 

Recently uploaded

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 

Recently uploaded (20)

Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 

Fundamentals of Programming Chapter 6

  • 1. C H AP T E R 6 B R AN C H I N G PROG0101 FUNDAMENTALS OF PROGRAMMING Chapter 5 Operators PROG0101 FUNDAMENTALS OF PROGRAMMING CHAPTER 4 VARIABLES AND DATA TYPES PROG0101 FUNDAMENTALS OF PROGRAMMING CHAPTER 3 ALGORITHMS PROG0101 FUNDAMENTALS OF PROGRAMMING C H A P T E R 1 O V E R V I E W O F C O M P U T E R S A N D L O G I C PROG0101 FUNDAMENTALS OF PROGRAMMING PROG0101 FUNDAMENTALS OF PROGRAMMING CHAPTER 6 BRANCHING STATEMENTS
  • 2. 2 BRANCHING STATEMENTS Branching Statements  A program consists of a number of statements which are usually executed in sequence.  Programs can be much more powerful if we can control the order in which statements are run.  The Branching Statements or Control Statements let the program makes a decision about what to do next.
  • 3. 3 BRANCHING STATEMENTS Branching Statements  Examples of Branching Statements in programming:  IF Statement  Switch Statement
  • 4. 4 IF STATEMENT  The IF Statement is a powerful decision making statement and is used to control the flow of execution of statements.  It is basically a two-way decision statement and is used in conjunction with an expression.
  • 5. 5 IF STATEMENT  It allows the computer to evaluate the expression first and then, depending on whether the value of the expression (relation or condition) is ' true ' (non-zero) or ' false ' (zero), it transfers the control to a particular statement.  This point of program has two paths to follow, one for the true condition and the other for the false condition.  The if statement may be implemented in different forms depending on the complexity of the conditions to be tested.
  • 6. 6 IF STATEMENT IF Statement  Two types of IF Statement:  Simple IF Statement  IF-ELSE Statement
  • 7. 7 IF STATEMENT Simple IF Statement  The statement-block may be a single statement or a group of statements.  If the test expression is true, the statement-block will be executed; otherwise the statement-block will be skipped and the execution will jump to statement-x.  Remember, when the condition is true both the statement- block and the statement-x are executed in sequence.
  • 9. 9 IF STATEMENT IF-ELSE Statement  The if....else statement is an extension of the simple if statement.  If the test expression is true , then the true-block statement(s), immediately following the if statement are executed; otherwise the false-block statement(s) are executed.  In either case, either true-block or false-block will be executed, not both.
  • 11. 11 IF STATEMENT Example 1 The flow chart shows a program which ask a user to enter a number, and then compare the number given either it is bigger or smaller than 5.
  • 12. 12 IF STATEMENT Example 2 The flow chart shows a program to check whether the student “Passed” or “Failed”.
  • 13. 13 SWITCH STATEMENT  In computer programming, a Switch Statement (also known as Case Statement) is a type of control statement that exists in most modern imperative programming languages.  This is another form of the multi way decision.  A switch statement is a selection statement that lets you transfer control to different statements within the switch body depending on the value of the switch expression.
  • 14. 14 SWITCH STATEMENT  If the value of the switch expression equals the value of one of the case expressions, the statements following that case expression are processed.  If not, the default label statements, if any, are processed.