SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler 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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Semelhante a 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
 

Semelhante a 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
 

Mais de 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
 

Mais de 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
 

Último

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
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
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
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
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
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
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Último (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
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
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
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
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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...
 
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?
 
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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

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