SlideShare a Scribd company logo
1 of 21
Download to read offline
CSC 103
Lecture 6
Introduction to Computers and Programming
Pseudo-code and Flow Charts
 There are two commonly used tools to help to
document program logic (the algorithm)
 These are:
 Flowcharts
 Graphical representation
 used for small problems
 Pseudo-code
 English and programming combination
 used for large problems
2
Pseudo-code
 Pseudo-Code is a numbered list of instructions to perform
some task
 Statements are written in simple English without regard to the
final programming language
 Each instruction is written on a separate line
 The pseudo-code is the program-like statements written for
human readers, not for computers
 Implementation is to translate the pseudo-code into programs,
such as “C” language programs
3
Writing Pseudo-code
 Number each instruction
 This is to enforce the notion of an ordered sequence of
operations
 Furthermore we introduce a dot notation (e.g. 3.1 come
after 3 but before 4) to number subordinate operations
for conditional and iterative operations
 Each instruction should be unambiguous and effective
 Completeness: Nothing is left out
4
Basic Elements of Pseudo-code
 A Variable
 Having name and value
 There are two operations performed on a variable
 Assignment Operation is the one in which we associate
a value to a variable.
 The other operation is the one in which at any given
time we intend to retrieve the value previously assigned
to that variable (Read Operation)
5
Basic Operations of Pseudo-code
 Assignment Operation
 This operation associates a value to a variable.
 While writing Pseudo-code you may follow your own
syntax.
 Some of the possible syntaxes are:
 Assign 3 to x
 Set x equal to 3
 x=3
6
Basic Operations of Pseudo-code
 Read Operation
 In this operation we intend to retrieve the value
previously assigned to that variable. For example:
 Set Value of x equal to y
 Read the input from user
 This operation causes the algorithm to get the value of a
variable from the user.
 Get x
 Get a, b, c
7
Basic Operations of Pseudo-code
 Print the output to the user
 Print x (This will print value of variable x)
 Print “Your mileage is” x
 Carry out basic arithmetic computations
 Set x to 10
 Set y to x*x/3
8
Example: Pseudo-code of calculating area of circle
1. Begin
2. Input value for radius
3. Calculate area (pi x radius2
)
4. Output radius and area
5. Quit
THEN PROGRAM
9
Flow Chart
 Graphical representation of an
algorithm
 Some of the common symbols
used in flowcharts are shown:
Start/Stop
Preparation
Input/Output
Process
Decision
Connector
10
 With flowcharting, essential steps of an algorithm are
shown using the shapes above.
 The flow of data between steps is indicated by
arrows, or flowlines. For example, a flowchart (and
equivalent Pseudocode) to compute the interest on a
loan is shown below:
11
Pseudo-codeFlow chart
1. Read NAME, BALANCE, RATE
2. Compute INTEREST as BALANCE x RATE
3. Write (Display) NAME and INTEREST
Stop
Start
Read NAME,
BALANCE, RATE
INTEREST=BALANCE x RATE
Write NAME,
INTEREST
12
 Note that the Pseudo-code also describes the essential
steps to be taken, but without the graphical
enhancements.
 Another example of a flowchart and the equivalent
pseudo-code is shown next.
13
Pseudo-codeFlow chart
1. Read X,Y,Z
2. Compute Sum(S) as X+Y+Z
3. Compute Average(A) as S/3
4. Compute Product(P) as X x Y x Z
5. Write (Display) Sum, Average and Product
Stop
Start
Read X, Y and Z
S= X+Y+Z
A = S/3
P = X x Y x Z
Write S, A and P
14
Some Examples
 Write pseudo-code of a program that asks the user to
enter two numbers and prints the sum, product,
difference, and division of the two numbers.
 Write pseudo-code of a program that solves a
quadratic equation ax2+bx+c by taking a, b and c as
input from user.
15
Decision Making and Pseudo-code
16
Stop
Start
Read A, B
BIG = A
SMALL = B
Write BIG, SMALL
BIG = B
SMALL = A
A < B ?
YesNo
1. Read A, B
2. If A is less than B
2.1 BIG = B
2.2 SMALL = A
3. Else
3.1 BIG = A
3.2 SMALL = B
4. Write BIG, SMALL
Example
17
Loops and Pseudo-code
18
Start
K=1
K=K+1
K > 10?
Procedure
Stop
Yes
No
19
Draw the Flowchart
1. get hours worked
2. get pay rate
3. if hours worked ≤ 40 then
3.1 gross pay = pay rate times hours worked
4. else
4.1 gross pay = pay rate times 40 plus 1.5
times pay rate times (hours worked minus 40)
5. display gross pay
6. End
20
Draw the Flowchart
1. get number of quizzes
2. sum = 0
3. count = 0
4. while count < number of quizzes
4.1 get quiz grade
4.2 sum = sum + quiz grade
4.3 count = count + 1
5. average = sum / number of quizzes
6. display average
7. End
21

More Related Content

What's hot

Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowchartskhair20
 
Unit 3 Foc
Unit  3 FocUnit  3 Foc
Unit 3 FocJAYA
 
Ge6161 lab manual
Ge6161 lab manualGe6161 lab manual
Ge6161 lab manualMani Kandan
 
Chapter 2 Representation Of Algorithms 2
Chapter 2  Representation Of  Algorithms 2Chapter 2  Representation Of  Algorithms 2
Chapter 2 Representation Of Algorithms 2Li-Anne Serrano
 
Computer programming:Know How to Flowchart
Computer  programming:Know How to FlowchartComputer  programming:Know How to Flowchart
Computer programming:Know How to FlowchartAngelo Tomboc
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowchartsSamuel Igbanogu
 
25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manualkamesh dagia
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithmDHANIK VIKRANT
 
Flowchart and algorithem
Flowchart and algorithemFlowchart and algorithem
Flowchart and algorithemehsanullah786
 
Algorithms and flowcharts by Haseeb Khan
Algorithms and flowcharts by Haseeb KhanAlgorithms and flowcharts by Haseeb Khan
Algorithms and flowcharts by Haseeb KhanHaseeb Shalmani
 
Pseudocode & flowchart examples
Pseudocode & flowchart examplesPseudocode & flowchart examples
Pseudocode & flowchart exampleshayrikk
 
Algorithms, flow charts and pseudocodes
Algorithms, flow charts and pseudocodesAlgorithms, flow charts and pseudocodes
Algorithms, flow charts and pseudocodesSatveer Mann
 
Pseudocode-Flowchart
Pseudocode-FlowchartPseudocode-Flowchart
Pseudocode-Flowchartlotlot
 

What's hot (20)

Pseudocode
PseudocodePseudocode
Pseudocode
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
 
Unit 3 Foc
Unit  3 FocUnit  3 Foc
Unit 3 Foc
 
Ge6161 lab manual
Ge6161 lab manualGe6161 lab manual
Ge6161 lab manual
 
Chapter 2 Representation Of Algorithms 2
Chapter 2  Representation Of  Algorithms 2Chapter 2  Representation Of  Algorithms 2
Chapter 2 Representation Of Algorithms 2
 
Computer programming:Know How to Flowchart
Computer  programming:Know How to FlowchartComputer  programming:Know How to Flowchart
Computer programming:Know How to Flowchart
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
 
Algorithm itabq
Algorithm itabqAlgorithm itabq
Algorithm itabq
 
25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual25422733 c-programming-and-data-structures-lab-manual
25422733 c-programming-and-data-structures-lab-manual
 
Flowchart and algorithm
Flowchart and algorithmFlowchart and algorithm
Flowchart and algorithm
 
Flowchart and algorithem
Flowchart and algorithemFlowchart and algorithem
Flowchart and algorithem
 
Algorithms and flowcharts by Haseeb Khan
Algorithms and flowcharts by Haseeb KhanAlgorithms and flowcharts by Haseeb Khan
Algorithms and flowcharts by Haseeb Khan
 
Flowcharts
FlowchartsFlowcharts
Flowcharts
 
Penyelesaian masalah
Penyelesaian masalahPenyelesaian masalah
Penyelesaian masalah
 
Pseudocode & flowchart examples
Pseudocode & flowchart examplesPseudocode & flowchart examples
Pseudocode & flowchart examples
 
Pseudocode
PseudocodePseudocode
Pseudocode
 
Algorithms, flow charts and pseudocodes
Algorithms, flow charts and pseudocodesAlgorithms, flow charts and pseudocodes
Algorithms, flow charts and pseudocodes
 
Pseudocode-Flowchart
Pseudocode-FlowchartPseudocode-Flowchart
Pseudocode-Flowchart
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
Unit 3
Unit 3Unit 3
Unit 3
 

Similar to ICP - Lecture 6

Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and FlowchartsDeva Singh
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptReshuReshma8
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowchartsmoazwinner
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer scienceumardanjumamaiwada
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfSusieMaestre1
 
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.pptLecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.pptcosc242101003
 
algorithms and flow chart overview.pdf
algorithms and flow chart overview.pdfalgorithms and flow chart overview.pdf
algorithms and flow chart overview.pdfAmanPratik11
 
Oop lab assignment 01
Oop lab assignment 01Oop lab assignment 01
Oop lab assignment 01Drjilesh
 
C chap02
C chap02C chap02
C chap02Kamran
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2lemonmichelangelo
 
01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.ppt01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.pptFerdieBalang
 

Similar to ICP - Lecture 6 (20)

3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3Fundamentals of Programming Chapter 3
Fundamentals of Programming Chapter 3
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
C++
C++C++
C++
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowcharts
 
lecture 5
 lecture 5 lecture 5
lecture 5
 
Introduction to computer science
Introduction to computer scienceIntroduction to computer science
Introduction to computer science
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
Flowcharting and Algorithm
Flowcharting and Algorithm Flowcharting and Algorithm
Flowcharting and Algorithm
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdf
 
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.pptLecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
Lecture_01-Problem_Solving[1]||ProgrammingFundamental.ppt
 
algorithms and flow chart overview.pdf
algorithms and flow chart overview.pdfalgorithms and flow chart overview.pdf
algorithms and flow chart overview.pdf
 
Oop lab assignment 01
Oop lab assignment 01Oop lab assignment 01
Oop lab assignment 01
 
C chap02
C chap02C chap02
C chap02
 
C chap02
C chap02C chap02
C chap02
 
LMmanual.pdf
LMmanual.pdfLMmanual.pdf
LMmanual.pdf
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
 
01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.ppt01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.ppt
 

More from Hassaan Rahman

Lecture#12 preservation of hadees
Lecture#12 preservation of hadeesLecture#12 preservation of hadees
Lecture#12 preservation of hadeesHassaan Rahman
 
Isl. lecture#11 ahadees
Isl. lecture#11 ahadeesIsl. lecture#11 ahadees
Isl. lecture#11 ahadeesHassaan Rahman
 
Isl. lecture#10 the miracle of the holy qura'n
Isl. lecture#10 the miracle of the holy qura'nIsl. lecture#10 the miracle of the holy qura'n
Isl. lecture#10 the miracle of the holy qura'nHassaan Rahman
 
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)Isl. lecture#9 compilation in the time of hazrat usman (r.a.)
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)Hassaan Rahman
 
Isl. lecture#8 the holy qura'n
Isl. lecture#8 the holy qura'nIsl. lecture#8 the holy qura'n
Isl. lecture#8 the holy qura'nHassaan Rahman
 
Isl. lecture#7 risalat
Isl. lecture#7 risalatIsl. lecture#7 risalat
Isl. lecture#7 risalatHassaan Rahman
 
ECA - Source Transformation
ECA - Source TransformationECA - Source Transformation
ECA - Source TransformationHassaan Rahman
 
Isl. lecture#6 effect of tawheed
Isl. lecture#6 effect of tawheedIsl. lecture#6 effect of tawheed
Isl. lecture#6 effect of tawheedHassaan Rahman
 
Isl. lecture#5 tawheed
Isl. lecture#5 tawheedIsl. lecture#5 tawheed
Isl. lecture#5 tawheedHassaan Rahman
 
Electric Circuit - Lecture 04
Electric Circuit - Lecture 04Electric Circuit - Lecture 04
Electric Circuit - Lecture 04Hassaan Rahman
 
Isl. lecture#3 need of islam
Isl. lecture#3 need of islamIsl. lecture#3 need of islam
Isl. lecture#3 need of islamHassaan Rahman
 
Lab 02 Resistor color coding and ohms law
Lab 02   Resistor color coding and ohms lawLab 02   Resistor color coding and ohms law
Lab 02 Resistor color coding and ohms lawHassaan Rahman
 

More from Hassaan Rahman (20)

Step natural
Step naturalStep natural
Step natural
 
Lecture#12 preservation of hadees
Lecture#12 preservation of hadeesLecture#12 preservation of hadees
Lecture#12 preservation of hadees
 
Isl. lecture#11 ahadees
Isl. lecture#11 ahadeesIsl. lecture#11 ahadees
Isl. lecture#11 ahadees
 
Isl. lecture#10 the miracle of the holy qura'n
Isl. lecture#10 the miracle of the holy qura'nIsl. lecture#10 the miracle of the holy qura'n
Isl. lecture#10 the miracle of the holy qura'n
 
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)Isl. lecture#9 compilation in the time of hazrat usman (r.a.)
Isl. lecture#9 compilation in the time of hazrat usman (r.a.)
 
Circuits
CircuitsCircuits
Circuits
 
Isl. lecture#8 the holy qura'n
Isl. lecture#8 the holy qura'nIsl. lecture#8 the holy qura'n
Isl. lecture#8 the holy qura'n
 
Isl. lecture#7 risalat
Isl. lecture#7 risalatIsl. lecture#7 risalat
Isl. lecture#7 risalat
 
Thev norton eq
Thev norton eqThev norton eq
Thev norton eq
 
ECA - Source Transformation
ECA - Source TransformationECA - Source Transformation
ECA - Source Transformation
 
Isl. lecture#6 effect of tawheed
Isl. lecture#6 effect of tawheedIsl. lecture#6 effect of tawheed
Isl. lecture#6 effect of tawheed
 
Isl. lecture#5 tawheed
Isl. lecture#5 tawheedIsl. lecture#5 tawheed
Isl. lecture#5 tawheed
 
Circuits5
Circuits5Circuits5
Circuits5
 
Electric Circuit - Lecture 04
Electric Circuit - Lecture 04Electric Circuit - Lecture 04
Electric Circuit - Lecture 04
 
ECA - Lecture 03
ECA - Lecture 03ECA - Lecture 03
ECA - Lecture 03
 
Isl. lecture#4 islam
Isl. lecture#4 islamIsl. lecture#4 islam
Isl. lecture#4 islam
 
Isl. lecture#3 need of islam
Isl. lecture#3 need of islamIsl. lecture#3 need of islam
Isl. lecture#3 need of islam
 
ICP - Lecture 7 and 8
ICP - Lecture 7 and 8ICP - Lecture 7 and 8
ICP - Lecture 7 and 8
 
ICP - Lecture 5
ICP - Lecture 5ICP - Lecture 5
ICP - Lecture 5
 
Lab 02 Resistor color coding and ohms law
Lab 02   Resistor color coding and ohms lawLab 02   Resistor color coding and ohms law
Lab 02 Resistor color coding and ohms law
 

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

ICP - Lecture 6

  • 1. CSC 103 Lecture 6 Introduction to Computers and Programming
  • 2. Pseudo-code and Flow Charts  There are two commonly used tools to help to document program logic (the algorithm)  These are:  Flowcharts  Graphical representation  used for small problems  Pseudo-code  English and programming combination  used for large problems 2
  • 3. Pseudo-code  Pseudo-Code is a numbered list of instructions to perform some task  Statements are written in simple English without regard to the final programming language  Each instruction is written on a separate line  The pseudo-code is the program-like statements written for human readers, not for computers  Implementation is to translate the pseudo-code into programs, such as “C” language programs 3
  • 4. Writing Pseudo-code  Number each instruction  This is to enforce the notion of an ordered sequence of operations  Furthermore we introduce a dot notation (e.g. 3.1 come after 3 but before 4) to number subordinate operations for conditional and iterative operations  Each instruction should be unambiguous and effective  Completeness: Nothing is left out 4
  • 5. Basic Elements of Pseudo-code  A Variable  Having name and value  There are two operations performed on a variable  Assignment Operation is the one in which we associate a value to a variable.  The other operation is the one in which at any given time we intend to retrieve the value previously assigned to that variable (Read Operation) 5
  • 6. Basic Operations of Pseudo-code  Assignment Operation  This operation associates a value to a variable.  While writing Pseudo-code you may follow your own syntax.  Some of the possible syntaxes are:  Assign 3 to x  Set x equal to 3  x=3 6
  • 7. Basic Operations of Pseudo-code  Read Operation  In this operation we intend to retrieve the value previously assigned to that variable. For example:  Set Value of x equal to y  Read the input from user  This operation causes the algorithm to get the value of a variable from the user.  Get x  Get a, b, c 7
  • 8. Basic Operations of Pseudo-code  Print the output to the user  Print x (This will print value of variable x)  Print “Your mileage is” x  Carry out basic arithmetic computations  Set x to 10  Set y to x*x/3 8
  • 9. Example: Pseudo-code of calculating area of circle 1. Begin 2. Input value for radius 3. Calculate area (pi x radius2 ) 4. Output radius and area 5. Quit THEN PROGRAM 9
  • 10. Flow Chart  Graphical representation of an algorithm  Some of the common symbols used in flowcharts are shown: Start/Stop Preparation Input/Output Process Decision Connector 10
  • 11.  With flowcharting, essential steps of an algorithm are shown using the shapes above.  The flow of data between steps is indicated by arrows, or flowlines. For example, a flowchart (and equivalent Pseudocode) to compute the interest on a loan is shown below: 11
  • 12. Pseudo-codeFlow chart 1. Read NAME, BALANCE, RATE 2. Compute INTEREST as BALANCE x RATE 3. Write (Display) NAME and INTEREST Stop Start Read NAME, BALANCE, RATE INTEREST=BALANCE x RATE Write NAME, INTEREST 12
  • 13.  Note that the Pseudo-code also describes the essential steps to be taken, but without the graphical enhancements.  Another example of a flowchart and the equivalent pseudo-code is shown next. 13
  • 14. Pseudo-codeFlow chart 1. Read X,Y,Z 2. Compute Sum(S) as X+Y+Z 3. Compute Average(A) as S/3 4. Compute Product(P) as X x Y x Z 5. Write (Display) Sum, Average and Product Stop Start Read X, Y and Z S= X+Y+Z A = S/3 P = X x Y x Z Write S, A and P 14
  • 15. Some Examples  Write pseudo-code of a program that asks the user to enter two numbers and prints the sum, product, difference, and division of the two numbers.  Write pseudo-code of a program that solves a quadratic equation ax2+bx+c by taking a, b and c as input from user. 15
  • 16. Decision Making and Pseudo-code 16
  • 17. Stop Start Read A, B BIG = A SMALL = B Write BIG, SMALL BIG = B SMALL = A A < B ? YesNo 1. Read A, B 2. If A is less than B 2.1 BIG = B 2.2 SMALL = A 3. Else 3.1 BIG = A 3.2 SMALL = B 4. Write BIG, SMALL Example 17
  • 20. Draw the Flowchart 1. get hours worked 2. get pay rate 3. if hours worked ≤ 40 then 3.1 gross pay = pay rate times hours worked 4. else 4.1 gross pay = pay rate times 40 plus 1.5 times pay rate times (hours worked minus 40) 5. display gross pay 6. End 20
  • 21. Draw the Flowchart 1. get number of quizzes 2. sum = 0 3. count = 0 4. while count < number of quizzes 4.1 get quiz grade 4.2 sum = sum + quiz grade 4.3 count = count + 1 5. average = sum / number of quizzes 6. display average 7. End 21