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

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Recently uploaded (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

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