SlideShare a Scribd company logo
3
Most read
8
Most read
12
Most read
Pseudocode

       For
 Program Design


                  1
Flowcharts vs Pseudocode
Flowcharts were the first design tool to be
widely used, but unfortunately they do not
reflect some of the concepts of structured
programming very well.
 Pseudocode, on the other hand, is a newer tool
and has features that make it more reflective of
the structured concepts.
The drawback is that the narrative presentation
is not as easy to understand and/or follow.
                                                   2
Rules for Pseudocode
Write only one statement per line
Capitalise initial keyword
Indent to show hierarchy and structures
End multiline structures
Keep statements language independent
  Remember you are describing a logic plan to develop
  a program, you are not programming!



                                                        3
One Statement Per Line
Each statement in pseudocode should express
just one action for the computer.
  Note capitals for the initial keywords
                    Pseudocode
         READ name, hoursWorked, payRate
         gross = hoursWorked * payRate
         WRITE name, hoursWorked, gross

These are just a few of the keywords to use,
others include
  READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE
                                                  4
Indent to Show Hierarchy
Sequence:
  Keep statements in sequence all starting in the same column
Selection:                             READ name, grossPay, taxes
                                       IF taxes > 0
  IF, ELSE (or ELSEIF), ENDIF
                                            net = grossPay – taxes
  must be in line
                                       ELSE
  Indent all statements that depend       net = grossPay
  on a condition                       ENDIF
Loop:                                  WRITE name, net
                                       count = 0
  WHILE, ENDWHILE
                                       WHILE count < 10
  Indent statements that fall inside       ADD 1 to count
  the loop but not keywords that          WRITE count
  form the loop                        ENDWHILE
  Also REPEAT, UNTIL                   WRITE “The End”
                                                                     5
The Selection Structure

             yes                    no
                     amount < 100




interestRate = .06                   interestRate = .10




                                                  IF amount < 100
                                                      interestRate = .06
                          Pseudocode             ELSE
                                                     InterestRate = .10
                                                  ENDIF

                                                                           6
The Looping Structure
In flowcharting one of the more confusing things
is to separate selection from looping. This is
because each structure use the diamond as their
control symbol.
Pseudocode avoids this by using specific
keywords to designate looping
  WHILE / ENDWHILE: condition checked before loop
  REPEAT / UNTIL: condition checked after loop



                                                    7
WHILE / ENDWHILE
   Start
                          count = 0
                          WHILE count < 10
                              ADD 1 to count
 count = 0
                              WRITE count
                          ENDWHILE
                          WRITE “The End”

   count
                          Mainline
    <10
                                                Modular
                          count = 0
                Write     WHILE count < 10
   add 1 to   “The End”
    count                     DO Process
                          ENDWHILE
                Stop
write count               WRITE “The End”

                          Process
                          ADD 1 to count
                          WRITE count
                                                           8
REPEAT / UNTIL
   Start             count = 0
                     REPEAT
 count = 0
                         ADD 1 to count
                         WRITE count
                     UNTIL count >= 10
   add 1 to          WRITE “The End”
    count

                     Mainline
                                           Modular
 write count         count = 0
                     REPEAT
                         DO Process
   count
    <10              UNTIL count >= 10
                     WRITE “The End”

  Write              Process
“The End”
                     ADD 1 to count
  Stop               WRITE count
                                                      9
Flowchart vs Pseudocode
Flowchart Advantages:          Pseudocode Advantages
  Standardized                   Easily modified
  Visual                         Implements structured
                                 concepts
                                 Done easily on Word
                                 Processor

Flowchart Disadvantages:       Pseudocode
  Hard to modify               Disadvantages:
  Structured design elements     Not visual
  not implemented                No accepted standard, varies
  Special software required      from company to company

                                                                10
Access of Data
The READ statement tells the computer to get a
value from an input device and store it in a memory
location.
  How to deal with memory locations which have been
  allocated an address e.g. 19087
Give them names (field or variable names)
  Using descriptive words e.g. Total as opposed to a
  location addresses




                                                       11
Rules for Variable Names
Begin with lowercase letter
Contain no spaces
Additional words begin with capital
Unique names within code
Consistent use of names




                                      12
Working with Fields
        Calculations           Selection
+       add              >    greater than
-       subtract         <    less than
*       multiply         =    equal to
/       divide           >=   greater than or equal to
** or ^ exponentiation   <=   less than or equal to
()      grouping         <>   not equal to




                                                         13

More Related Content

What's hot (20)

PPTX
Insertion Sorting
FarihaHabib123
 
PPTX
Algorithm and flowchart
Rabin BK
 
PPTX
Set data structure
Tech_MX
 
PDF
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
vtunotesbysree
 
PPTX
Introduction to Coding
St. Petersburg College
 
PPTX
10 hexadecimal number system
Lee Chadwick
 
PPTX
Computer Architecture – An Introduction
Dilum Bandara
 
PPT
Introduction to Compiler Construction
Sarmad Ali
 
PPTX
Programming fundamentals lecture 4
Raja Hamid
 
PPTX
Stacks and Queue - Data Structures
Dr. Jasmine Beulah Gnanadurai
 
PDF
Pseudocode & flowchart examples
hayrikk
 
PPTX
Algorithm
IHTISHAM UL HAQ
 
PDF
Applications of stack
eShikshak
 
PPTX
sorting and its types
SIVASHANKARIRAJAN
 
PPTX
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
PPTX
Conversion of Infix to Prefix and Postfix with Stack
sahil kumar
 
PDF
Python GUI
LusciousLarryDas
 
PDF
8086 assembly
Shehrevar Davierwala
 
PDF
Introduction to algorithms
subhashchandra197
 
Insertion Sorting
FarihaHabib123
 
Algorithm and flowchart
Rabin BK
 
Set data structure
Tech_MX
 
VTU 3RD SEM UNIX AND SHELL PROGRAMMING SOLVED PAPERS
vtunotesbysree
 
Introduction to Coding
St. Petersburg College
 
10 hexadecimal number system
Lee Chadwick
 
Computer Architecture – An Introduction
Dilum Bandara
 
Introduction to Compiler Construction
Sarmad Ali
 
Programming fundamentals lecture 4
Raja Hamid
 
Stacks and Queue - Data Structures
Dr. Jasmine Beulah Gnanadurai
 
Pseudocode & flowchart examples
hayrikk
 
Algorithm
IHTISHAM UL HAQ
 
Applications of stack
eShikshak
 
sorting and its types
SIVASHANKARIRAJAN
 
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
Conversion of Infix to Prefix and Postfix with Stack
sahil kumar
 
Python GUI
LusciousLarryDas
 
8086 assembly
Shehrevar Davierwala
 
Introduction to algorithms
subhashchandra197
 

Similar to Pseudocode flowcharts (20)

PPT
Pseudocode basics
kiran_kaur
 
PPT
Modul Mata Kuliah Desain Prodi Sistem InformasiAgoritma.ppt
karuniaman
 
DOC
Unit 2
rohassanie
 
PPT
9 cm604.12
myrajendra
 
PPT
Computer Programming - Lecture 2
Dr. Md. Shohel Sayeed
 
PPT
our c prog work
sravan kumar
 
PPT
Unit 3 Foc
JAYA
 
PPTX
Flowchat
chamaiporn tinsomrat
 
PPSX
Flowchat
chamaiporn tinsomrat
 
PDF
LEC 5 [CS 101] Introduction to computer science.pdf
p87783936
 
PPT
9 cm604.12
myrajendra
 
PPT
Algorithm Designs - Control Structures
hatredai
 
PPT
Cmp104 lec 7 algorithm and flowcharts
kapil078
 
DOC
Pseudocode
Guy09
 
PPT
Algorithms
nicky_walters
 
PPT
C Language Unit-1
kasaragadda srinivasrao
 
PPTX
ICT_Seminar_flow_charts_for_2013_Nov.pptx
ssuser2f67c91
 
PDF
Pseudocode By ZAK
Tabsheer Hasan
 
PPTX
Introduction to Flowcharts
Damian T. Gordon
 
PPSX
Flowchat
chamaiporn tinsomrat
 
Pseudocode basics
kiran_kaur
 
Modul Mata Kuliah Desain Prodi Sistem InformasiAgoritma.ppt
karuniaman
 
Unit 2
rohassanie
 
9 cm604.12
myrajendra
 
Computer Programming - Lecture 2
Dr. Md. Shohel Sayeed
 
our c prog work
sravan kumar
 
Unit 3 Foc
JAYA
 
LEC 5 [CS 101] Introduction to computer science.pdf
p87783936
 
9 cm604.12
myrajendra
 
Algorithm Designs - Control Structures
hatredai
 
Cmp104 lec 7 algorithm and flowcharts
kapil078
 
Pseudocode
Guy09
 
Algorithms
nicky_walters
 
C Language Unit-1
kasaragadda srinivasrao
 
ICT_Seminar_flow_charts_for_2013_Nov.pptx
ssuser2f67c91
 
Pseudocode By ZAK
Tabsheer Hasan
 
Introduction to Flowcharts
Damian T. Gordon
 
Ad

More from nicky_walters (20)

PPTX
Design documentation
nicky_walters
 
PPTX
Software development lifecycle
nicky_walters
 
PPTX
Data structures vb
nicky_walters
 
PPTX
Design for edp
nicky_walters
 
PPTX
Data types vbnet
nicky_walters
 
PPTX
Data types vbnet
nicky_walters
 
PPTX
Data types vbnet
nicky_walters
 
PPTX
Ndu06 typesof language
nicky_walters
 
PPTX
Ndu06 typesof language
nicky_walters
 
PPTX
Event driventheory
nicky_walters
 
PPTX
Simple debugging
nicky_walters
 
PPTX
Simple debugging
nicky_walters
 
PPTX
Debugging
nicky_walters
 
PPTX
Using loops
nicky_walters
 
PPTX
Input output
nicky_walters
 
PPTX
Decisions
nicky_walters
 
PPTX
Decisions
nicky_walters
 
PPTX
Controls
nicky_walters
 
PPTX
Decisions
nicky_walters
 
PPTX
Intro to visual studio 2008
nicky_walters
 
Design documentation
nicky_walters
 
Software development lifecycle
nicky_walters
 
Data structures vb
nicky_walters
 
Design for edp
nicky_walters
 
Data types vbnet
nicky_walters
 
Data types vbnet
nicky_walters
 
Data types vbnet
nicky_walters
 
Ndu06 typesof language
nicky_walters
 
Ndu06 typesof language
nicky_walters
 
Event driventheory
nicky_walters
 
Simple debugging
nicky_walters
 
Simple debugging
nicky_walters
 
Debugging
nicky_walters
 
Using loops
nicky_walters
 
Input output
nicky_walters
 
Decisions
nicky_walters
 
Decisions
nicky_walters
 
Controls
nicky_walters
 
Decisions
nicky_walters
 
Intro to visual studio 2008
nicky_walters
 
Ad

Pseudocode flowcharts

  • 1. Pseudocode For Program Design 1
  • 2. Flowcharts vs Pseudocode Flowcharts were the first design tool to be widely used, but unfortunately they do not reflect some of the concepts of structured programming very well. Pseudocode, on the other hand, is a newer tool and has features that make it more reflective of the structured concepts. The drawback is that the narrative presentation is not as easy to understand and/or follow. 2
  • 3. Rules for Pseudocode Write only one statement per line Capitalise initial keyword Indent to show hierarchy and structures End multiline structures Keep statements language independent Remember you are describing a logic plan to develop a program, you are not programming! 3
  • 4. One Statement Per Line Each statement in pseudocode should express just one action for the computer. Note capitals for the initial keywords Pseudocode READ name, hoursWorked, payRate gross = hoursWorked * payRate WRITE name, hoursWorked, gross These are just a few of the keywords to use, others include READ, WRITE, IF, ELSE, ENDIF, WHILE, ENDWHILE 4
  • 5. Indent to Show Hierarchy Sequence: Keep statements in sequence all starting in the same column Selection: READ name, grossPay, taxes IF taxes > 0 IF, ELSE (or ELSEIF), ENDIF net = grossPay – taxes must be in line ELSE Indent all statements that depend net = grossPay on a condition ENDIF Loop: WRITE name, net count = 0 WHILE, ENDWHILE WHILE count < 10 Indent statements that fall inside ADD 1 to count the loop but not keywords that WRITE count form the loop ENDWHILE Also REPEAT, UNTIL WRITE “The End” 5
  • 6. The Selection Structure yes no amount < 100 interestRate = .06 interestRate = .10 IF amount < 100 interestRate = .06 Pseudocode  ELSE InterestRate = .10 ENDIF 6
  • 7. The Looping Structure In flowcharting one of the more confusing things is to separate selection from looping. This is because each structure use the diamond as their control symbol. Pseudocode avoids this by using specific keywords to designate looping WHILE / ENDWHILE: condition checked before loop REPEAT / UNTIL: condition checked after loop 7
  • 8. WHILE / ENDWHILE Start count = 0 WHILE count < 10 ADD 1 to count count = 0 WRITE count ENDWHILE WRITE “The End” count Mainline <10  Modular count = 0 Write WHILE count < 10 add 1 to “The End” count DO Process ENDWHILE Stop write count WRITE “The End” Process ADD 1 to count WRITE count 8
  • 9. REPEAT / UNTIL Start count = 0 REPEAT count = 0 ADD 1 to count WRITE count UNTIL count >= 10 add 1 to WRITE “The End” count Mainline  Modular write count count = 0 REPEAT DO Process count <10 UNTIL count >= 10 WRITE “The End” Write Process “The End” ADD 1 to count Stop WRITE count 9
  • 10. Flowchart vs Pseudocode Flowchart Advantages: Pseudocode Advantages Standardized Easily modified Visual Implements structured concepts Done easily on Word Processor Flowchart Disadvantages: Pseudocode Hard to modify Disadvantages: Structured design elements Not visual not implemented No accepted standard, varies Special software required from company to company 10
  • 11. Access of Data The READ statement tells the computer to get a value from an input device and store it in a memory location. How to deal with memory locations which have been allocated an address e.g. 19087 Give them names (field or variable names) Using descriptive words e.g. Total as opposed to a location addresses 11
  • 12. Rules for Variable Names Begin with lowercase letter Contain no spaces Additional words begin with capital Unique names within code Consistent use of names 12
  • 13. Working with Fields Calculations Selection + add > greater than - subtract < less than * multiply = equal to / divide >= greater than or equal to ** or ^ exponentiation <= less than or equal to () grouping <> not equal to 13