SlideShare a Scribd company logo
1 of 14
DECISION CONSTRUCTS
CHAPTER # 11
SUBJECT: COMPUTER ICS (PART II)
Presented By :
Prof. HASEEB ASLAM
M.Phil. (IT)
( CONCORDIA GROUP OF COLLEGES GUJRANWALA)
1
CONTROL STRUCTURE
 A statement used to
control the flow of execution in program
is called control structure.
Used to
 Combine individual instruction into single logical unit.
 Logical Unit has One entry point and
One exit point.
-: Types :-
1. Sequence
2. Selection
3. Repetition
4. Functional Call
2
CONCORDIA
COLLEGE
GUJRANWALA
TYPES OF CONTROL STRUCTURE
1. Sequence:-
In sequential structure
 Statements are executed in same order.
 (in which they are written in program).
 Control flows one statement to other in
logical sequence.
 All statements are executed only once.
It means
 No statement is skipped
 No statement is executed more than once 3
ASPIRE
COLLEGE
WAZIRABAD
TYPES OF CONTROL STRUCTURE
2. Selection:-
In selection structure selects a statement or set of
statements
 are executed on the basis of condition
 If condition is true
Statements are executed
 If condition is false
Statements are not executed.
-:Types:-
1. If
2. If-else
3. switch 4
ASPIRE
COLLEGE
WAZIRABAD
TYPES OF CONTROL STRUCTURE
3. Repetition:-
In repetition structure statement or set of statements
 are executed repeatedly.
 It is also known as iteration structure or LOOP.
-:Types:-
1. For loop
2. While loop
3. Do-while loop
5
ASPIRE
COLLEGE
WAZIRABAD
TYPES OF CONTROL STRUCTURE
4. Functional Call:-
Functional call is a statement that
 Moves the control to another block of code.
Control returns back after
 Executing all statements in block.
 Remaining statements executed immediately
after function call when control is returned.
6
ASPIRE
COLLEGE
WAZIRABAD
SELECTION STRUCTURE
A selection statement selects a statement or set of statements
 are executed on the basis of condition
 If condition is true
Statements are executed
 If condition is false
Statements are not executed.
-:Example:-
 Suppose program displays Pass
if marks 40 OR more than 40.
 It displays fail
if marks are below 40.
 Program checks the marks before displaying message.
 This process is called decision-making or selection. 7
ASPIRE
COLLEGE
WAZIRABAD
TYPES OF SELECTION STRUCTURE
1. If-else Structure:-
 It is used to execute or
 Skip a statement or set of statements
by using a condition.
2. Switch Structure:-
It is used
• When there are many choices available &
Only one should be executed.
8
ASPIRE
COLLEGE
WAZIRABAD
IF STATEMENT / IF STATEMENT WITH ONE
ALTERNATIVE
 If is a keyword in c language.
 If is decision making statement.
 It is simplest form of selection constructs.
 It is used to execute or
Skip a statement or set of statements
by checking a condition.
Condition is available in relational expression.
If condition is true
statements are executed.
If condition is false
statements are not executed. 9
ASPIRE
COLLEGE
WAZIRABAD
IF STATEMENT / IF STATEMENT WITH ONE
ALTERNATIVE
-:Syntax:-
if ( condition )
statement ;
if (condition )
{
Statements
}
10
ASPIRE
COLLEGE
WAZIRABAD
NESTED IF
11
ASPIRE
COLLEGE
WAZIRABAD
if ( condition )
else
{
Statements ;
}
if ( condition )
{
Statements ;
}
else if ( condition )
{
Statements;
}
else
{
Statements;
}
NESTED IF
An if statement within
 another if statement
is called nested if.
In nested structure
 Control enters into inner if
only when outer condition is true.
 Only one block is executed
& remaining are skipped automatically.
 User can use many if statements
inside another if statement if required.
 Increase in level of nesting increases
complexity of nested if statement.
12
ASPIRE
COLLEGE
WAZIRABAD
FLOW CHART OF NESTED IF
13
ASPIRE
COLLEGE
WAZIRABAD
DIFFERENCE B/W
‘ NESTED IF ’ & ‘ IF ’ STATEMENT
An if statement within
 another if statement
is called nested if.
In nested structure
 Control enters into inner if
only when outer condition is true.
 Only one block is executed
& remaining are skipped automatically.
 User can use many if statements
inside another if statement if required.
 Increase in level of nesting increases
complexity of nested if statement.
14
ASPIRE
COLLEGE
WAZIRABAD

More Related Content

Similar to Ch # 11 2nd year computer science notes1

Similar to Ch # 11 2nd year computer science notes1 (20)

Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 
Decision making and branching
Decision making and branchingDecision making and branching
Decision making and branching
 
UNIT 2 PPT.pdf
UNIT 2 PPT.pdfUNIT 2 PPT.pdf
UNIT 2 PPT.pdf
 
Comp ppt (1)
Comp ppt (1)Comp ppt (1)
Comp ppt (1)
 
2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes2nd year computer science chapter 12 notes
2nd year computer science chapter 12 notes
 
Control statements in Java
Control statements  in JavaControl statements  in Java
Control statements in Java
 
BSc. III Unit iii VB.NET
BSc. III Unit iii VB.NETBSc. III Unit iii VB.NET
BSc. III Unit iii VB.NET
 
Control structures in java
Control structures in javaControl structures in java
Control structures in java
 
C sharp chap4
C sharp chap4C sharp chap4
C sharp chap4
 
Java.pptx
Java.pptxJava.pptx
Java.pptx
 
Control structures
Control structuresControl structures
Control structures
 
Control Structures in Visual Basic
Control Structures in  Visual BasicControl Structures in  Visual Basic
Control Structures in Visual Basic
 
2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt2. Control structures with for while and do while.ppt
2. Control structures with for while and do while.ppt
 
Control statement
Control statementControl statement
Control statement
 
C++ chapter 4
C++ chapter 4C++ chapter 4
C++ chapter 4
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
 
Control structures in c
Control structures in cControl structures in c
Control structures in c
 
Programming Fundamentals in C++ structures
Programming Fundamentals in  C++ structuresProgramming Fundamentals in  C++ structures
Programming Fundamentals in C++ structures
 
VB.Net Mod2.pptx
VB.Net Mod2.pptxVB.Net Mod2.pptx
VB.Net Mod2.pptx
 
Chapter05-Control Structures.pptx
Chapter05-Control Structures.pptxChapter05-Control Structures.pptx
Chapter05-Control Structures.pptx
 

Recently uploaded

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
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 GraphThiyagu K
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
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 ImpactPECB
 
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
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 

Recently uploaded (20)

TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).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
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
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
 
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
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
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
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 

Ch # 11 2nd year computer science notes1

  • 1. DECISION CONSTRUCTS CHAPTER # 11 SUBJECT: COMPUTER ICS (PART II) Presented By : Prof. HASEEB ASLAM M.Phil. (IT) ( CONCORDIA GROUP OF COLLEGES GUJRANWALA) 1
  • 2. CONTROL STRUCTURE  A statement used to control the flow of execution in program is called control structure. Used to  Combine individual instruction into single logical unit.  Logical Unit has One entry point and One exit point. -: Types :- 1. Sequence 2. Selection 3. Repetition 4. Functional Call 2 CONCORDIA COLLEGE GUJRANWALA
  • 3. TYPES OF CONTROL STRUCTURE 1. Sequence:- In sequential structure  Statements are executed in same order.  (in which they are written in program).  Control flows one statement to other in logical sequence.  All statements are executed only once. It means  No statement is skipped  No statement is executed more than once 3 ASPIRE COLLEGE WAZIRABAD
  • 4. TYPES OF CONTROL STRUCTURE 2. Selection:- In selection structure selects a statement or set of statements  are executed on the basis of condition  If condition is true Statements are executed  If condition is false Statements are not executed. -:Types:- 1. If 2. If-else 3. switch 4 ASPIRE COLLEGE WAZIRABAD
  • 5. TYPES OF CONTROL STRUCTURE 3. Repetition:- In repetition structure statement or set of statements  are executed repeatedly.  It is also known as iteration structure or LOOP. -:Types:- 1. For loop 2. While loop 3. Do-while loop 5 ASPIRE COLLEGE WAZIRABAD
  • 6. TYPES OF CONTROL STRUCTURE 4. Functional Call:- Functional call is a statement that  Moves the control to another block of code. Control returns back after  Executing all statements in block.  Remaining statements executed immediately after function call when control is returned. 6 ASPIRE COLLEGE WAZIRABAD
  • 7. SELECTION STRUCTURE A selection statement selects a statement or set of statements  are executed on the basis of condition  If condition is true Statements are executed  If condition is false Statements are not executed. -:Example:-  Suppose program displays Pass if marks 40 OR more than 40.  It displays fail if marks are below 40.  Program checks the marks before displaying message.  This process is called decision-making or selection. 7 ASPIRE COLLEGE WAZIRABAD
  • 8. TYPES OF SELECTION STRUCTURE 1. If-else Structure:-  It is used to execute or  Skip a statement or set of statements by using a condition. 2. Switch Structure:- It is used • When there are many choices available & Only one should be executed. 8 ASPIRE COLLEGE WAZIRABAD
  • 9. IF STATEMENT / IF STATEMENT WITH ONE ALTERNATIVE  If is a keyword in c language.  If is decision making statement.  It is simplest form of selection constructs.  It is used to execute or Skip a statement or set of statements by checking a condition. Condition is available in relational expression. If condition is true statements are executed. If condition is false statements are not executed. 9 ASPIRE COLLEGE WAZIRABAD
  • 10. IF STATEMENT / IF STATEMENT WITH ONE ALTERNATIVE -:Syntax:- if ( condition ) statement ; if (condition ) { Statements } 10 ASPIRE COLLEGE WAZIRABAD
  • 11. NESTED IF 11 ASPIRE COLLEGE WAZIRABAD if ( condition ) else { Statements ; } if ( condition ) { Statements ; } else if ( condition ) { Statements; } else { Statements; }
  • 12. NESTED IF An if statement within  another if statement is called nested if. In nested structure  Control enters into inner if only when outer condition is true.  Only one block is executed & remaining are skipped automatically.  User can use many if statements inside another if statement if required.  Increase in level of nesting increases complexity of nested if statement. 12 ASPIRE COLLEGE WAZIRABAD
  • 13. FLOW CHART OF NESTED IF 13 ASPIRE COLLEGE WAZIRABAD
  • 14. DIFFERENCE B/W ‘ NESTED IF ’ & ‘ IF ’ STATEMENT An if statement within  another if statement is called nested if. In nested structure  Control enters into inner if only when outer condition is true.  Only one block is executed & remaining are skipped automatically.  User can use many if statements inside another if statement if required.  Increase in level of nesting increases complexity of nested if statement. 14 ASPIRE COLLEGE WAZIRABAD