0% found this document useful (0 votes)
5 views6 pages

Week 4-1

Programming fundamentals

Uploaded by

asgharzainab877
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views6 pages

Week 4-1

Programming fundamentals

Uploaded by

asgharzainab877
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Control Structure

“Statements used to control the flow of


execution in a program”
• Control structure decide what will be the flow
of program execution.
• Control structure determine In which order
the statements of the program will execute
• Control Structures used to implement
program logic
• Also known as logic structure
Types of Control Structure in C++
There are four basic types control structure to
implement program logic in C++
1. Sequential
2. Selection / Branching / Decision
3. Repetition / Loop / Iteration
4. Function Call
5. Jump Statements
Sequential Structure
• The statements of a program
will execute in same order in Statement 1
which they are written
• The control flow from one
statement to another in logical Statement 2
sequence
Examples
▪ variable declaration and initialization
▪ Input statement ( cin>> variable ; ) Statement 3
▪ Output statement (cout<< constant or
variable or expression ; )
Selection Structure
• Also known as conditional or
decision structure True False
• The execution of statement
depend on the condition Action 1 Action 2

Examples
▪ If (also called single selection)
▪ If-else (also called double selection)
▪ If-else-if
▪ Switch (also called multiple selection)
Iterative Structure
• Used to repeat a statement or
False
set of statement until certain
condition met.
• Also called loop or repetition True

Examples Body of loop


• for ( counter controlled loop)
• while
• do-while Conditional Loop Exit from loop
Function Call
• Function call statement is Statement 1
used to shift the flow of Function
Statement
control to the called .
function. Function Call .
.
• The statements of function return
only run when function is
Function Call
invoked or called

Function is name block of code to


perform some specific task

You might also like