SlideShare a Scribd company logo
1 of 16
Flow of Control
In computer science, control flow (or
alternatively, flow of control) refers
to the specification of the order in
which the individual statements,
instructions or function calls of an
imperative program are executed or
evaluated.
Flow of Control
Selection
Switch
If-else
Sequence Iteration (Loop)
Do-while loop
While, for loop
Statements
 Simple Statements: These are single statements. Eg:
If(a>0)
cout<<a;
 Compound Statements: It is a group of statements separated from each other by a
semicolon(;). This group of statements is also called a block of code enclosed within a pair
of curly braces { }. Its significance is that the group of statements under curly braces is
treated as one unit. Eg:
If(a>0)
{
b==a;
cout<<b;
}
Precedence of operators
 In C++ and other programming languages, compiler works according to
certain priority and order of operators which is also termed as precedence
of operators.
Selection (If else)
 If else statements are used to control flow of compiler on the basis of given
condition is true or false. If the condition is true then it executes the if
block otherwise moves out of the block.
 Syntax:
If(condition)
{
code block;
}
If-else
 This is in addition to If statement. It includes ‘else’ block after ‘if’ block. If the ‘if’
block condition is false then the compiler moves in else block or vice versa.
Syntax:
If(condition)
{
code block;
}
else
{
code block;
}
E.g.:
If(c==0)
{
b=1;
cout<<a;
}
else
{
cout<<d;
}
Nested If else or If else Ladder
Switch Case
 This statement is used when we have to
select one option out of many
alternatives. It is a multi branch
statement that makes the control to
jump to one of the several statements
based on the value of an integer
variable or an expression. The general
form of the switch is:
Iteration Statement
 Iteration statements cause statements (or compound
statements) to be executed zero or more times, subject
to some loop-termination criteria. When these
statements are compound statements, they are
executed in order, except when either
the break statement or the continue statement is
encountered.
While loop
 It is executed repeatedly until or unless the condition is false. There must
be some loop terminating or updating conditions inside the loop code
block to avoid infinite looping.
Syntax:
while(expression)
{
statement;
statement;
}
For Loop
 It is similar to while loop except it contains three
parts in its expression i.e. initialization, condition,
updation in variable.
 Syntax:
for(initialization; condition; updation)
{
statement;
}
Jump Statements:
 Break statement: The break statement ends execution of the nearest
enclosing loop or conditional statement in which it appears. Control passes
to the statement that follows the end of the statement, if any.
 Continue Statement: Forces transfer of control to the controlling
expression of the smallest enclosing do, for, or while loop.
 Exit Statement: The exit() function stops the program. exit_code is passed
on to be the return value of the program, where usually zero indicates
success and non-zero indicates an error.

More Related Content

What's hot

Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming FundamentalsKIU
 
Conditional statement
Conditional statementConditional statement
Conditional statementMaxie Santos
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statementsKuppusamy P
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJTANUJ ⠀
 
Decision control structures
Decision control structuresDecision control structures
Decision control structuresRahul Bathri
 
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
 
Selection statements
Selection statementsSelection statements
Selection statementsHarsh Dabas
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
The Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming ConceptsThe Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming ConceptsTech
 
Conditional statements
Conditional statementsConditional statements
Conditional statementscherrybear2014
 
Control Structures
Control StructuresControl Structures
Control StructuresGhaffar Khan
 
Jumping statements
Jumping statementsJumping statements
Jumping statementsSuneel Dogra
 
Diploma ii cfpc u-3 handling input output and control statements
Diploma ii  cfpc u-3 handling input output and control statementsDiploma ii  cfpc u-3 handling input output and control statements
Diploma ii cfpc u-3 handling input output and control statementsRai University
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C pptMANJUTRIPATHI7
 

What's hot (20)

Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Conditional statement
Conditional statementConditional statement
Conditional statement
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 
Flow of control C ++ By TANUJ
Flow of control C ++ By TANUJFlow of control C ++ By TANUJ
Flow of control C ++ By TANUJ
 
Decision control structures
Decision control structuresDecision control structures
Decision control structures
 
Control statement-Selective
Control statement-SelectiveControl statement-Selective
Control statement-Selective
 
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
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
 
Selection statements
Selection statementsSelection statements
Selection statements
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
The Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming ConceptsThe Three Basic Selection Structures in C++ Programming Concepts
The Three Basic Selection Structures in C++ Programming Concepts
 
Control statement in c
Control statement in cControl statement in c
Control statement in c
 
Conditional statements
Conditional statementsConditional statements
Conditional statements
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
Control Structures
Control StructuresControl Structures
Control Structures
 
Flow of Control
Flow of ControlFlow of Control
Flow of Control
 
Java control flow statements
Java control flow statementsJava control flow statements
Java control flow statements
 
Jumping statements
Jumping statementsJumping statements
Jumping statements
 
Diploma ii cfpc u-3 handling input output and control statements
Diploma ii  cfpc u-3 handling input output and control statementsDiploma ii  cfpc u-3 handling input output and control statements
Diploma ii cfpc u-3 handling input output and control statements
 
Decision Making Statement in C ppt
Decision Making Statement in C pptDecision Making Statement in C ppt
Decision Making Statement in C ppt
 

Viewers also liked

AHC Social Media Marketing
AHC Social Media MarketingAHC Social Media Marketing
AHC Social Media MarketingTrevor Beemon
 
Value Voice 2016 AHSP 24x18 Faded Faces Print 03
Value Voice 2016 AHSP 24x18 Faded Faces Print 03Value Voice 2016 AHSP 24x18 Faded Faces Print 03
Value Voice 2016 AHSP 24x18 Faded Faces Print 03Selen Ermanav
 
Esfera dos livros - setembro
Esfera dos  livros - setembroEsfera dos  livros - setembro
Esfera dos livros - setembropjpl
 
15. 十字真言
15. 十字真言15. 十字真言
15. 十字真言hkyeung
 
A performance comparison of proposed approach of multiserver authentication a...
A performance comparison of proposed approach of multiserver authentication a...A performance comparison of proposed approach of multiserver authentication a...
A performance comparison of proposed approach of multiserver authentication a...eSAT Journals
 
Transportation Marketplace
Transportation MarketplaceTransportation Marketplace
Transportation MarketplaceChris Sheffer
 
Eric siu gmail and-yt-ads-12-5-2016
Eric siu gmail and-yt-ads-12-5-2016Eric siu gmail and-yt-ads-12-5-2016
Eric siu gmail and-yt-ads-12-5-2016Vasil Azarov
 
Saurabh neuroscience. final
Saurabh neuroscience. finalSaurabh neuroscience. final
Saurabh neuroscience. finalsaurabh jadhav
 
사이버컴과 네트워크분석 12주차 2
사이버컴과 네트워크분석 12주차 2사이버컴과 네트워크분석 12주차 2
사이버컴과 네트워크분석 12주차 2Han Woo PARK
 
Pepsico 2nd Report
Pepsico 2nd ReportPepsico 2nd Report
Pepsico 2nd ReportFaraaz Gani
 
SQL Joinning.Database
SQL Joinning.DatabaseSQL Joinning.Database
SQL Joinning.DatabaseUmme habiba
 

Viewers also liked (16)

Resume 2016
Resume 2016Resume 2016
Resume 2016
 
AHC Social Media Marketing
AHC Social Media MarketingAHC Social Media Marketing
AHC Social Media Marketing
 
Value Voice 2016 AHSP 24x18 Faded Faces Print 03
Value Voice 2016 AHSP 24x18 Faded Faces Print 03Value Voice 2016 AHSP 24x18 Faded Faces Print 03
Value Voice 2016 AHSP 24x18 Faded Faces Print 03
 
CV_RAULT-Alexis
CV_RAULT-AlexisCV_RAULT-Alexis
CV_RAULT-Alexis
 
Esfera dos livros - setembro
Esfera dos  livros - setembroEsfera dos  livros - setembro
Esfera dos livros - setembro
 
36706
3670636706
36706
 
15. 十字真言
15. 十字真言15. 十字真言
15. 十字真言
 
A performance comparison of proposed approach of multiserver authentication a...
A performance comparison of proposed approach of multiserver authentication a...A performance comparison of proposed approach of multiserver authentication a...
A performance comparison of proposed approach of multiserver authentication a...
 
Documents system
Documents systemDocuments system
Documents system
 
Transportation Marketplace
Transportation MarketplaceTransportation Marketplace
Transportation Marketplace
 
Eric siu gmail and-yt-ads-12-5-2016
Eric siu gmail and-yt-ads-12-5-2016Eric siu gmail and-yt-ads-12-5-2016
Eric siu gmail and-yt-ads-12-5-2016
 
Saurabh neuroscience. final
Saurabh neuroscience. finalSaurabh neuroscience. final
Saurabh neuroscience. final
 
사이버컴과 네트워크분석 12주차 2
사이버컴과 네트워크분석 12주차 2사이버컴과 네트워크분석 12주차 2
사이버컴과 네트워크분석 12주차 2
 
Pepsico 2nd Report
Pepsico 2nd ReportPepsico 2nd Report
Pepsico 2nd Report
 
joins in database
 joins in database joins in database
joins in database
 
SQL Joinning.Database
SQL Joinning.DatabaseSQL Joinning.Database
SQL Joinning.Database
 

Similar to Flow of control

Mca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statementsMca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statementsRai University
 
handling input output and control statements
 handling input output and control statements handling input output and control statements
handling input output and control statementsRai University
 
Btech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statementsBtech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statementsRai University
 
Bsc cs pic u-3 handling input output and control statements
Bsc cs  pic u-3 handling input output and control statementsBsc cs  pic u-3 handling input output and control statements
Bsc cs pic u-3 handling input output and control statementsRai University
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition StructureShahzu2
 
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.pptManojKhadilkar1
 
Programming Fundamentals in C++ structures
Programming Fundamentals in  C++ structuresProgramming Fundamentals in  C++ structures
Programming Fundamentals in C++ structuresayshasafdarwaada
 
Control structures
Control structuresControl structures
Control structuresGehad Enayat
 
web presentation 138.pptx
web presentation 138.pptxweb presentation 138.pptx
web presentation 138.pptxAbhiYadav655132
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop typesRj Baculo
 

Similar to Flow of control (20)

C++ chapter 4
C++ chapter 4C++ chapter 4
C++ chapter 4
 
Mca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statementsMca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statements
 
handling input output and control statements
 handling input output and control statements handling input output and control statements
handling input output and control statements
 
Btech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statementsBtech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statements
 
CONTROL STMTS.pptx
CONTROL STMTS.pptxCONTROL STMTS.pptx
CONTROL STMTS.pptx
 
Bsc cs pic u-3 handling input output and control statements
Bsc cs  pic u-3 handling input output and control statementsBsc cs  pic u-3 handling input output and control statements
Bsc cs pic u-3 handling input output and control statements
 
Comp ppt (1)
Comp ppt (1)Comp ppt (1)
Comp ppt (1)
 
Do While Repetition Structure
Do While Repetition StructureDo While Repetition Structure
Do While Repetition Structure
 
Loops
LoopsLoops
Loops
 
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
 
Programming Fundamentals in C++ structures
Programming Fundamentals in  C++ structuresProgramming Fundamentals in  C++ structures
Programming Fundamentals in C++ structures
 
6.pptx
6.pptx6.pptx
6.pptx
 
Programming in Arduino (Part 2)
Programming in Arduino  (Part 2)Programming in Arduino  (Part 2)
Programming in Arduino (Part 2)
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
 
Control statements
Control statementsControl statements
Control statements
 
Control structures
Control structuresControl structures
Control structures
 
web presentation 138.pptx
web presentation 138.pptxweb presentation 138.pptx
web presentation 138.pptx
 
C language 2
C language 2C language 2
C language 2
 
Cpp loop types
Cpp loop typesCpp loop types
Cpp loop types
 
Control structures in C
Control structures in CControl structures in C
Control structures in C
 

Recently uploaded

buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Recently uploaded (20)

buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

Flow of control

  • 2. In computer science, control flow (or alternatively, flow of control) refers to the specification of the order in which the individual statements, instructions or function calls of an imperative program are executed or evaluated.
  • 3. Flow of Control Selection Switch If-else Sequence Iteration (Loop) Do-while loop While, for loop
  • 4. Statements  Simple Statements: These are single statements. Eg: If(a>0) cout<<a;  Compound Statements: It is a group of statements separated from each other by a semicolon(;). This group of statements is also called a block of code enclosed within a pair of curly braces { }. Its significance is that the group of statements under curly braces is treated as one unit. Eg: If(a>0) { b==a; cout<<b; }
  • 5. Precedence of operators  In C++ and other programming languages, compiler works according to certain priority and order of operators which is also termed as precedence of operators.
  • 6. Selection (If else)  If else statements are used to control flow of compiler on the basis of given condition is true or false. If the condition is true then it executes the if block otherwise moves out of the block.  Syntax: If(condition) { code block; }
  • 7. If-else  This is in addition to If statement. It includes ‘else’ block after ‘if’ block. If the ‘if’ block condition is false then the compiler moves in else block or vice versa. Syntax: If(condition) { code block; } else { code block; }
  • 9. Nested If else or If else Ladder
  • 10. Switch Case  This statement is used when we have to select one option out of many alternatives. It is a multi branch statement that makes the control to jump to one of the several statements based on the value of an integer variable or an expression. The general form of the switch is:
  • 11. Iteration Statement  Iteration statements cause statements (or compound statements) to be executed zero or more times, subject to some loop-termination criteria. When these statements are compound statements, they are executed in order, except when either the break statement or the continue statement is encountered.
  • 12. While loop  It is executed repeatedly until or unless the condition is false. There must be some loop terminating or updating conditions inside the loop code block to avoid infinite looping. Syntax: while(expression) { statement; statement; }
  • 13.
  • 14. For Loop  It is similar to while loop except it contains three parts in its expression i.e. initialization, condition, updation in variable.  Syntax: for(initialization; condition; updation) { statement; }
  • 15.
  • 16. Jump Statements:  Break statement: The break statement ends execution of the nearest enclosing loop or conditional statement in which it appears. Control passes to the statement that follows the end of the statement, if any.  Continue Statement: Forces transfer of control to the controlling expression of the smallest enclosing do, for, or while loop.  Exit Statement: The exit() function stops the program. exit_code is passed on to be the return value of the program, where usually zero indicates success and non-zero indicates an error.