SlideShare a Scribd company logo
Computing in Engineering
Computers and Systems Engineering Dept
• Using Subprocesses to simplify program design
• Nested Loops
• Arrays
• Exam-like questions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
• Using Subprocesses to simplify program design
• Nested Loops
• Arrays
• Exam-like questions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Using Subprocesses in Flowcharts
• Flowcharts of a complex process can
be broken down into smaller sub-
processes for clarity and re-usability.
• In this case a flowchart can point to a
different sub-process within its flow.
• The predefined process symbol to the
right is used to show such
subprocesses.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
The subprocess is useful because:
• it permits the modularization of complex programs.
• it provides a means of simplifying programs by making common
processes available to a wide number of programs.
• it makes for more reliable programs since once it is shown that a
process works then it can be made a subprocess and need not be tested
again.
• In flow charts subprocesses are also useful in dealing with the
flowcharting rule that a flow chart should have no more than 15 or so
symbols on a page.
Using Subprocesses in Flowcharts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
How to decide which sub-programs are needed?
• Break the program into subtasks
• Examine each subtask and break it down if
needed into further subtasks
• Continue until the subtask cannot be broken
down into small subtasks
• Example: Baking a cake
Using Subprocesses in Flowcharts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
What are things/tasks you have to do to make a
cake?
• Ingredient preparation
• Process the ingredients
• Assemble the cake
Using Subprocesses in Flowcharts
Example 1 : Baking a cake
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Using Subprocesses in Flowcharts
Example 1: Baking a cake
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Using Subprocesses in Flowcharts
Example 2: Read temperature in Fahrenheit and print its
value in both Fahrenheit and Celcius
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Using Subprocesses in Flowcharts
Example 3: Maximum of 3 Integers Revisited
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
• Using Subprocesses to simplify program design
• Nested Loops
• Arrays
• Exam-like questions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
•Nested loops are loops placed inside one another
creating a loop of loops.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Mock Example Revisited
Nested Loops
Pseudocode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Nested Loops
Flowchart
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Problem: Design using flowchart
and pseudocode a program that
prints a figure similar to the one
on the right for a given number of rows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Problem: Design using flowchart
and pseudocode a program that
prints a figure similar to the one
on the right for a given number of rows.
Analysis:
Inputs : None.
Variables: N, Row_No, where:
1. N = No of Rows = 9
2. Row_No changes from 1:N
Steps:
For each row
1. Calculate number of stars
2. Print ‘*’ ( N - Row_No +1 ) times on the same row
3. New Line
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Start
For Row_No =1 To N
No_of_stars=N-Row_No+1
For Col =1 To No_of_stars
Print ‘*’;
End For
New line
End For
Stop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Hint:
Adding an “;” at the end of the Print statement
prevents skipping to the next line after printing
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
• Typically used for
working with two dimensions (or more)
such as in the above example
•When a loop is nested inside another loop,
the inner loop runs many times
inside the outer loop.
•In each iteration of the outer loop,
the inner loop will be re-started.
•The inner loop must finish all of its iterations
•before the outer loop can continue to its next iteration.
•The inner loop must have a different name for its
loop counter variable so that it will not conflict with the outer loop.
For Row_No =1,N
No_of_stars=N - Row_No +1
For Col =1, No_of_stars
Print ‘*’
End For
New line
End For
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Design a program that types the binary numbers corresponding to the integers 0 – 7
Analysis:
Inputs: None
Define 3 variables A, B, C as the binary digits needed to represent the numbers from 0 -7
Initial values: A=0, B=0, C=0
Output: 0 000
1 001
2 010
.
.
7 111
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
• Using Subprocesses to simplify program design
• Nested Loops
• Arrays
• Exam-like questions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
An array is a
collection of items of
same data type stored
at consecutive
memory locations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Basic array functions:
• Assigning values to
array elements
• Reading values
from array
elements
• Simple search
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Start
Read the number of elements n
Initialize i=0
Repeat
Read element no i
increment i
Until i = n
Initialize i=0
Repeat
write element no i
increment i
Until i = n
End
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Assumption:
The array “a” is already filled
with N numbers, and N >=0
Print
largest
End
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Given an array arr[] of N elements, the task is
to write a function to search a given
element x in arr[].
Example
Input: arr[] = {10, 20, 80, 30, 60, 50,110, 100,
130, 170}, x = 110;
Output: 6
Explanation: Element x is present at index 6
Input: arr[] = {10, 20, 80, 30, 60, 50,110, 100,
130, 170}, x = 175;
Output: -1
Explanation: Element x is not present in arr[].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Input x, array
found = False
Length = array size
counter =0
WHILE found = False AND counter < length
IF array[counter] = x
THEN
Print counter
found = True
ELSE
counter = counter + 1
END IF
END WHILE
IF found = False
THEN
print 'Item not found’
END IF
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Input x, array
Length = array size
counter =0
WHILE counter < length
IF array[counter] = x
THEN
Print counter
counter = length
END IF
counter = counter + 1
END WHILE
IF counter = length
THEN
print 'Item not found’
END IF
• Using Subprocesses to simplify program design
• Nested Loops
• Arrays
• Exam-like questions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Exam-like Question III
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Exam-Like Problem IV
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
Thank You

More Related Content

Similar to CSE031.Lecture_07-FlowCharts_Pseudocode .Part_II.pdf

Solution of matlab chapter 6
Solution of matlab chapter 6Solution of matlab chapter 6
Solution of matlab chapter 6
AhsanIrshad8
 
just reference
just referencejust reference
just reference
Sumin Kim
 
upload
uploadupload
upload
Sumin Kim
 
Basic math
Basic mathBasic math
Basic math
FathimaRifa
 
M1S1U2 (ADDITION STRATEGIES + DOUBLING CONCEPT)
M1S1U2 (ADDITION STRATEGIES + DOUBLING CONCEPT)M1S1U2 (ADDITION STRATEGIES + DOUBLING CONCEPT)
M1S1U2 (ADDITION STRATEGIES + DOUBLING CONCEPT)
EA Clavel
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
Ravikiran A
 
MNIST 10-class Classifiers
MNIST 10-class ClassifiersMNIST 10-class Classifiers
MNIST 10-class Classifiers
Sheetal Gangakhedkar
 
Basic college mathematics 3rd edition by julie mille neill hyde solutions manual
Basic college mathematics 3rd edition by julie mille neill hyde solutions manualBasic college mathematics 3rd edition by julie mille neill hyde solutions manual
Basic college mathematics 3rd edition by julie mille neill hyde solutions manual
tokahenrbar
 
Turning point multiply by two digits
Turning point multiply by two digitsTurning point multiply by two digits
Turning point multiply by two digitsTheresa Miller
 
UNIT I_PSPP - Illustrative Problems (1).pptx
UNIT I_PSPP - Illustrative Problems (1).pptxUNIT I_PSPP - Illustrative Problems (1).pptx
UNIT I_PSPP - Illustrative Problems (1).pptx
RSathyaPriyaCSEKIOT
 
Counting and Sequences
Counting and SequencesCounting and Sequences
Counting and Sequences
Dan Stewart
 
R part I
R part IR part I
R part I
Ruru Chowdhury
 
PEA 305.pdf
PEA 305.pdfPEA 305.pdf
PEA 305.pdf
SofiaSingla3
 
Maths
MathsMaths
01 - 01 January - Sorting
01 - 01 January - Sorting01 - 01 January - Sorting
01 - 01 January - Sorting
Neeldhara Misra
 
SCA_Module Supply Chain Data Analytics Supply Chain Data Analytics Supply Cha...
SCA_Module Supply Chain Data Analytics Supply Chain Data Analytics Supply Cha...SCA_Module Supply Chain Data Analytics Supply Chain Data Analytics Supply Cha...
SCA_Module Supply Chain Data Analytics Supply Chain Data Analytics Supply Cha...
MujtabaAliKhan12
 
Sudoku
SudokuSudoku
Sudoku
b p
 

Similar to CSE031.Lecture_07-FlowCharts_Pseudocode .Part_II.pdf (20)

Solution of matlab chapter 6
Solution of matlab chapter 6Solution of matlab chapter 6
Solution of matlab chapter 6
 
just reference
just referencejust reference
just reference
 
basics
basicsbasics
basics
 
upload
uploadupload
upload
 
Basic math
Basic mathBasic math
Basic math
 
M1S1U2 (ADDITION STRATEGIES + DOUBLING CONCEPT)
M1S1U2 (ADDITION STRATEGIES + DOUBLING CONCEPT)M1S1U2 (ADDITION STRATEGIES + DOUBLING CONCEPT)
M1S1U2 (ADDITION STRATEGIES + DOUBLING CONCEPT)
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
MNIST 10-class Classifiers
MNIST 10-class ClassifiersMNIST 10-class Classifiers
MNIST 10-class Classifiers
 
Basic college mathematics 3rd edition by julie mille neill hyde solutions manual
Basic college mathematics 3rd edition by julie mille neill hyde solutions manualBasic college mathematics 3rd edition by julie mille neill hyde solutions manual
Basic college mathematics 3rd edition by julie mille neill hyde solutions manual
 
Turning point multiply by two digits
Turning point multiply by two digitsTurning point multiply by two digits
Turning point multiply by two digits
 
UNIT I_PSPP - Illustrative Problems (1).pptx
UNIT I_PSPP - Illustrative Problems (1).pptxUNIT I_PSPP - Illustrative Problems (1).pptx
UNIT I_PSPP - Illustrative Problems (1).pptx
 
Counting and Sequences
Counting and SequencesCounting and Sequences
Counting and Sequences
 
Intro to maths for software eng
Intro to maths for software engIntro to maths for software eng
Intro to maths for software eng
 
R part I
R part IR part I
R part I
 
PEA 305.pdf
PEA 305.pdfPEA 305.pdf
PEA 305.pdf
 
Maths
MathsMaths
Maths
 
01 - 01 January - Sorting
01 - 01 January - Sorting01 - 01 January - Sorting
01 - 01 January - Sorting
 
SCA_Module Supply Chain Data Analytics Supply Chain Data Analytics Supply Cha...
SCA_Module Supply Chain Data Analytics Supply Chain Data Analytics Supply Cha...SCA_Module Supply Chain Data Analytics Supply Chain Data Analytics Supply Cha...
SCA_Module Supply Chain Data Analytics Supply Chain Data Analytics Supply Cha...
 
Sudoku
SudokuSudoku
Sudoku
 
DEL-244Chep i
DEL-244Chep iDEL-244Chep i
DEL-244Chep i
 

More from NourhanTarek23

CSE031.Lecture_05.Networks.pdf
CSE031.Lecture_05.Networks.pdfCSE031.Lecture_05.Networks.pdf
CSE031.Lecture_05.Networks.pdf
NourhanTarek23
 
CSE031.Lecture_11-Operating_Systems.Part_I.pptx
CSE031.Lecture_11-Operating_Systems.Part_I.pptxCSE031.Lecture_11-Operating_Systems.Part_I.pptx
CSE031.Lecture_11-Operating_Systems.Part_I.pptx
NourhanTarek23
 
Lect02 Introducing Programming.ppt
Lect02 Introducing Programming.pptLect02 Introducing Programming.ppt
Lect02 Introducing Programming.ppt
NourhanTarek23
 
Lect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.pptLect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.ppt
NourhanTarek23
 
Software engineering.pptx
Software engineering.pptxSoftware engineering.pptx
Software engineering.pptx
NourhanTarek23
 
Lect01 Computers Impact on Our lives IOT and Big Data Era.pptx
Lect01 Computers Impact on Our lives  IOT and Big Data Era.pptxLect01 Computers Impact on Our lives  IOT and Big Data Era.pptx
Lect01 Computers Impact on Our lives IOT and Big Data Era.pptx
NourhanTarek23
 
Lab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptxLab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptx
NourhanTarek23
 
section5.pptx
section5.pptxsection5.pptx
section5.pptx
NourhanTarek23
 
Introduction to computer.pptx
Introduction to computer.pptxIntroduction to computer.pptx
Introduction to computer.pptx
NourhanTarek23
 
AOP sec3.pptx
AOP sec3.pptxAOP sec3.pptx
AOP sec3.pptx
NourhanTarek23
 
Introduction to Spring sec2.pptx
Introduction to Spring sec2.pptxIntroduction to Spring sec2.pptx
Introduction to Spring sec2.pptx
NourhanTarek23
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptx
NourhanTarek23
 
QoS.pptx
QoS.pptxQoS.pptx
QoS.pptx
NourhanTarek23
 
’mobile ip.pptx
’mobile ip.pptx’mobile ip.pptx
’mobile ip.pptx
NourhanTarek23
 
Problem set 3-solution.pptx
Problem set 3-solution.pptxProblem set 3-solution.pptx
Problem set 3-solution.pptx
NourhanTarek23
 

More from NourhanTarek23 (15)

CSE031.Lecture_05.Networks.pdf
CSE031.Lecture_05.Networks.pdfCSE031.Lecture_05.Networks.pdf
CSE031.Lecture_05.Networks.pdf
 
CSE031.Lecture_11-Operating_Systems.Part_I.pptx
CSE031.Lecture_11-Operating_Systems.Part_I.pptxCSE031.Lecture_11-Operating_Systems.Part_I.pptx
CSE031.Lecture_11-Operating_Systems.Part_I.pptx
 
Lect02 Introducing Programming.ppt
Lect02 Introducing Programming.pptLect02 Introducing Programming.ppt
Lect02 Introducing Programming.ppt
 
Lect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.pptLect01 Introduction of Visual Basic.ppt
Lect01 Introduction of Visual Basic.ppt
 
Software engineering.pptx
Software engineering.pptxSoftware engineering.pptx
Software engineering.pptx
 
Lect01 Computers Impact on Our lives IOT and Big Data Era.pptx
Lect01 Computers Impact on Our lives  IOT and Big Data Era.pptxLect01 Computers Impact on Our lives  IOT and Big Data Era.pptx
Lect01 Computers Impact on Our lives IOT and Big Data Era.pptx
 
Lab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptxLab 7 - Bash Script.pptx
Lab 7 - Bash Script.pptx
 
section5.pptx
section5.pptxsection5.pptx
section5.pptx
 
Introduction to computer.pptx
Introduction to computer.pptxIntroduction to computer.pptx
Introduction to computer.pptx
 
AOP sec3.pptx
AOP sec3.pptxAOP sec3.pptx
AOP sec3.pptx
 
Introduction to Spring sec2.pptx
Introduction to Spring sec2.pptxIntroduction to Spring sec2.pptx
Introduction to Spring sec2.pptx
 
Introduction to Spring sec1.pptx
Introduction to Spring sec1.pptxIntroduction to Spring sec1.pptx
Introduction to Spring sec1.pptx
 
QoS.pptx
QoS.pptxQoS.pptx
QoS.pptx
 
’mobile ip.pptx
’mobile ip.pptx’mobile ip.pptx
’mobile ip.pptx
 
Problem set 3-solution.pptx
Problem set 3-solution.pptxProblem set 3-solution.pptx
Problem set 3-solution.pptx
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 

CSE031.Lecture_07-FlowCharts_Pseudocode .Part_II.pdf

  • 1. Computing in Engineering Computers and Systems Engineering Dept
  • 2. • Using Subprocesses to simplify program design • Nested Loops • Arrays • Exam-like questions 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 3. • Using Subprocesses to simplify program design • Nested Loops • Arrays • Exam-like questions 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 4. Using Subprocesses in Flowcharts • Flowcharts of a complex process can be broken down into smaller sub- processes for clarity and re-usability. • In this case a flowchart can point to a different sub-process within its flow. • The predefined process symbol to the right is used to show such subprocesses. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 5. The subprocess is useful because: • it permits the modularization of complex programs. • it provides a means of simplifying programs by making common processes available to a wide number of programs. • it makes for more reliable programs since once it is shown that a process works then it can be made a subprocess and need not be tested again. • In flow charts subprocesses are also useful in dealing with the flowcharting rule that a flow chart should have no more than 15 or so symbols on a page. Using Subprocesses in Flowcharts 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 6. How to decide which sub-programs are needed? • Break the program into subtasks • Examine each subtask and break it down if needed into further subtasks • Continue until the subtask cannot be broken down into small subtasks • Example: Baking a cake Using Subprocesses in Flowcharts 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 7. What are things/tasks you have to do to make a cake? • Ingredient preparation • Process the ingredients • Assemble the cake Using Subprocesses in Flowcharts Example 1 : Baking a cake 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 8. Using Subprocesses in Flowcharts Example 1: Baking a cake 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 9. Using Subprocesses in Flowcharts Example 2: Read temperature in Fahrenheit and print its value in both Fahrenheit and Celcius 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 10. Using Subprocesses in Flowcharts Example 3: Maximum of 3 Integers Revisited 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 11. • Using Subprocesses to simplify program design • Nested Loops • Arrays • Exam-like questions 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 12. •Nested loops are loops placed inside one another creating a loop of loops. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 13. Mock Example Revisited Nested Loops Pseudocode 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 14. Nested Loops Flowchart 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 15. Problem: Design using flowchart and pseudocode a program that prints a figure similar to the one on the right for a given number of rows 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 16. Problem: Design using flowchart and pseudocode a program that prints a figure similar to the one on the right for a given number of rows. Analysis: Inputs : None. Variables: N, Row_No, where: 1. N = No of Rows = 9 2. Row_No changes from 1:N Steps: For each row 1. Calculate number of stars 2. Print ‘*’ ( N - Row_No +1 ) times on the same row 3. New Line 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 17. Start For Row_No =1 To N No_of_stars=N-Row_No+1 For Col =1 To No_of_stars Print ‘*’; End For New line End For Stop 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 Hint: Adding an “;” at the end of the Print statement prevents skipping to the next line after printing
  • 18. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 19. • Typically used for working with two dimensions (or more) such as in the above example •When a loop is nested inside another loop, the inner loop runs many times inside the outer loop. •In each iteration of the outer loop, the inner loop will be re-started. •The inner loop must finish all of its iterations •before the outer loop can continue to its next iteration. •The inner loop must have a different name for its loop counter variable so that it will not conflict with the outer loop. For Row_No =1,N No_of_stars=N - Row_No +1 For Col =1, No_of_stars Print ‘*’ End For New line End For 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 20. Design a program that types the binary numbers corresponding to the integers 0 – 7 Analysis: Inputs: None Define 3 variables A, B, C as the binary digits needed to represent the numbers from 0 -7 Initial values: A=0, B=0, C=0 Output: 0 000 1 001 2 010 . . 7 111 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 21. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 22. • Using Subprocesses to simplify program design • Nested Loops • Arrays • Exam-like questions 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 23. An array is a collection of items of same data type stored at consecutive memory locations. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 24. Basic array functions: • Assigning values to array elements • Reading values from array elements • Simple search 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 25. Start Read the number of elements n Initialize i=0 Repeat Read element no i increment i Until i = n Initialize i=0 Repeat write element no i increment i Until i = n End 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 26. Assumption: The array “a” is already filled with N numbers, and N >=0 Print largest End 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 27. Given an array arr[] of N elements, the task is to write a function to search a given element x in arr[]. Example Input: arr[] = {10, 20, 80, 30, 60, 50,110, 100, 130, 170}, x = 110; Output: 6 Explanation: Element x is present at index 6 Input: arr[] = {10, 20, 80, 30, 60, 50,110, 100, 130, 170}, x = 175; Output: -1 Explanation: Element x is not present in arr[]. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 28. Input x, array found = False Length = array size counter =0 WHILE found = False AND counter < length IF array[counter] = x THEN Print counter found = True ELSE counter = counter + 1 END IF END WHILE IF found = False THEN print 'Item not found’ END IF 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 Input x, array Length = array size counter =0 WHILE counter < length IF array[counter] = x THEN Print counter counter = length END IF counter = counter + 1 END WHILE IF counter = length THEN print 'Item not found’ END IF
  • 29. • Using Subprocesses to simplify program design • Nested Loops • Arrays • Exam-like questions 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 30. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 31. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 32. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 33. Exam-like Question III 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 34. Exam-Like Problem IV 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
  • 35. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34