SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Using Pseudocode Statements
and Flowchart Symbols
Tools in Developing Programs
• Pseudocode is an English-like representation of the logical steps it takes to
solve a problem. Pseudo is a prefix that means false, and to code a program
means to put it in a programming language; therefore, pseudocode simply
means false code, or sentences that appear to have been written in a
computer programming language but do not necessarily follow all the
syntax rules of any specific language.
• Flowchart is a pictorial representation of the same thing.
Writing Pseudocode
The following five statements constitute a pseudocode
representation of a number-doubling problem:
start
input myNumber
set myAnswer = myNumber * 2
output myAnswer
stop
Writing Pseudocode
Using pseudocode involves writing down all the steps you will use in a
program. Usually, programmers preface their pseudocode with a beginning
statement like start and end it with a terminating statement like stop. The
statements between start and stop look like English and are indented
slightly so that start and stop stand out. Most programmers do not bother
with punctuation such as periods at the end of pseudocode statements,
although it would not be wrong to use them if you prefer that style.
Similarly, there is no need to capitalize the first word in a sentence,
although you might choose to do so.
Writing Pseudocode
Pseudocode is fairly flexible because it is a planning tool, and not the final product.
Therefore, for example, you might prefer any of the following:
• Instead of start and stop, some pseudocode developers would use other terms
such as begin and end.
• Instead of writing input myNumber, some developers would write get myNumber
or read myNumber.
• Instead of writing set myAnswer = myNumber * 2, some developers would write
calculate myAnswer = myNumber times 2 or compute myAnswer as myNumber
doubled.
• Instead of writing output myAnswer, many pseudocode developers would write
display myAnswer, print myAnswer, or write myAnswer
Writing Pseudocode
The point is, the pseudocode statements are instructions to retrieve an
original number from an input device and store it in memory where it can
be used in a calculation, and then to get the calculated answer from
memory and send it to an output device so a person can see it. When you
eventually convert your pseudocode to a specific programming language,
you do not have such flexibility because specific syntax will be required.
Flowcharts
Some professional programmers prefer writing pseudocode to drawing
flowcharts, because using pseudocode is more similar to writing the final
statements in the programming language. Others prefer drawing flowcharts
to represent the logical flow, because flowcharts allow programmers to
visualize more easily how the program statements will connect. Especially
for beginning programmers, flowcharts are an excellent tool to help them
visualize how the statements in a program are interrelated.
Flowcharts
You can draw a flowchart by hand or use software, such as Microsoft Word
and Microsoft PowerPoint, that contains flowcharting tools. You can use
several other software programs, such as Visio and Visual Logic, specifically
to create flowcharts. When you create a flowchart, you draw geometric
shapes that contain the individual statements and that are connected with
arrows.
Flowcharts
You use a parallelogram to represent an input symbol, which indicates an
input operation. You write an input statement in English inside the
parallelogram, as shown in the figure.
Flowcharts
Arithmetic operation statements are examples of processing. In a flowchart,
you use a rectangle as the processing symbol that contains a processing
statement, as shown in the figure.
Flowcharts
To represent an output statement, you use the same symbol as for input
statements—the output symbol is a parallelogram, as shown in the figure.
Because the parallelogram is used for both input and output, it is often
called the input/output symbol or I/O symbol.
Flowcharts
To show the correct sequence of these statements, you use arrows, or
flowlines, to connect the steps. Whenever possible, most of a flowchart
should read from top to bottom or from left to right on a page. That’s the
way we read English, so when flowcharts follow this convention, they are
easier for us to understand.
Flowcharts
To be complete, a flowchart should include two more elements: terminal
symbols, or start/ stop symbols, at each end. Often, you place a word like
start or begin in the first terminal symbol and a word like end or stop in the
other. The standard terminal symbol is shaped like a racetrack; many
programmers refer to this shape as a lozenge, because it resembles the
shape of the medication you might use to soothe a sore throat
Flowcharts
The figure shows a
complete flowchart for the
program that doubles a
number, and the
pseudocode for the same
problem.
You can see from the figure
that the flowchart and
pseudocode statements are
the same— only the
presentation format differs.
Using a Sentinel Value to End a Program
You represent a decision in a flowchart by drawing a decision symbol, which
is shaped like a diamond. The diamond usually contains a question, the
answer to which is one of two mutually exclusive options—often yes or no.
All good computer questions have only two mutually exclusive answers, such
as yes and no or true and false.
Using a Sentinel Value to End a Program
The question to stop the doubling program should
be “Is the value of myNumber just entered equal
to 0?” or “myNumber = 0?” for short. The
complete flowchart will look like the one shown
in the figure.
Using a Sentinel Value to End a Program
One drawback to using 0 to stop a program, of course, is that it won’t work
if the user does need to find the double of 0. In that case, some other data-
entry value that the user never will need, such as 999 or –1, could be
selected to signal that the program should end. A preselected value that
stops the execution of a program is often called a dummy value because it
does not represent real data, but just a signal to stop. Sometimes, such a
value is called a sentinel value because it represents an entry or exit point,
like a sentinel who guards a fortress.
Using a Sentinel Value to End a Program
Not all programs rely on user data entry from a keyboard; many read data
from an input device, such as a disk. When organizations store data on a disk
or other storage device, they do not commonly use a dummy value to signal
the end of the file.
Programming languages can recognize the end of data in a file automatically,
through a code that is stored at the end of the data. Many programming
languages use the term eof (for end of file) to refer to this marker that
automatically acts as a sentinel.
Using a Sentinel Value to End a Program
In the flowchart shown, the eof question is
shaded.
THANK YOU

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Ms powerpoint
Ms powerpointMs powerpoint
Ms powerpoint
 
Microsoft Office Introduction
Microsoft Office IntroductionMicrosoft Office Introduction
Microsoft Office Introduction
 
Multimedia presentation
  Multimedia presentation   Multimedia presentation
Multimedia presentation
 
Computer programming
Computer programmingComputer programming
Computer programming
 
Basic computer class 1
Basic computer class 1Basic computer class 1
Basic computer class 1
 
Python
PythonPython
Python
 
Application software and Peopleware
Application software and PeoplewareApplication software and Peopleware
Application software and Peopleware
 
Software ppt
Software pptSoftware ppt
Software ppt
 
Word processing
Word processing  Word processing
Word processing
 
Keyboarding skills
Keyboarding skillsKeyboarding skills
Keyboarding skills
 
Ms powerpoint
Ms powerpointMs powerpoint
Ms powerpoint
 
Intro. to PowerPoint
Intro. to PowerPointIntro. to PowerPoint
Intro. to PowerPoint
 
Introduction to ms windows
Introduction to ms windowsIntroduction to ms windows
Introduction to ms windows
 
Programming languages
Programming languagesProgramming languages
Programming languages
 
Difference between internet and www
Difference between internet and wwwDifference between internet and www
Difference between internet and www
 
Algorithm and psuedocode
Algorithm and psuedocodeAlgorithm and psuedocode
Algorithm and psuedocode
 
Programming Fundamental Presentation
Programming Fundamental PresentationProgramming Fundamental Presentation
Programming Fundamental Presentation
 
Welcome to word 2016
Welcome to word 2016Welcome to word 2016
Welcome to word 2016
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 

Ähnlich wie Using Pseudocode Statements and Flowchart Symbols

ProgFund_Lecture_7_Intro_C_Sequence.pdf
ProgFund_Lecture_7_Intro_C_Sequence.pdfProgFund_Lecture_7_Intro_C_Sequence.pdf
ProgFund_Lecture_7_Intro_C_Sequence.pdflailoesakhan
 
Data Structures and Algorithms presentation.pptx
Data Structures and Algorithms presentation.pptxData Structures and Algorithms presentation.pptx
Data Structures and Algorithms presentation.pptxChingChingErm
 
Data Structures and Algorithms presentation.pptx
Data Structures and Algorithms presentation.pptxData Structures and Algorithms presentation.pptx
Data Structures and Algorithms presentation.pptxChingChingErm
 
Programming process and flowchart
Programming process and flowchartProgramming process and flowchart
Programming process and flowcharthermiraguilar
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptxDivyaKS12
 
Unit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and FlowchartUnit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and FlowchartBom Khati
 
Learn Programming with Livecoding.tv http://goo.gl/tIgO1I
Learn Programming with Livecoding.tv http://goo.gl/tIgO1ILearn Programming with Livecoding.tv http://goo.gl/tIgO1I
Learn Programming with Livecoding.tv http://goo.gl/tIgO1Ilivecoding.tv
 
learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.pptfaithola1
 
C and its errors
C and its errorsC and its errors
C and its errorsJunaid Raja
 
10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechz10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechzShahbaz Ahmad
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and developmentAli Raza
 
Copy of dti2143/dam31303 chap 1 problem solving and program design
Copy of dti2143/dam31303 chap 1 problem solving and program designCopy of dti2143/dam31303 chap 1 problem solving and program design
Copy of dti2143/dam31303 chap 1 problem solving and program designalish sha
 

Ähnlich wie Using Pseudocode Statements and Flowchart Symbols (20)

Chapter 2- Prog101.ppt
Chapter 2- Prog101.pptChapter 2- Prog101.ppt
Chapter 2- Prog101.ppt
 
ProgFund_Lecture_7_Intro_C_Sequence.pdf
ProgFund_Lecture_7_Intro_C_Sequence.pdfProgFund_Lecture_7_Intro_C_Sequence.pdf
ProgFund_Lecture_7_Intro_C_Sequence.pdf
 
Data Structures and Algorithms presentation.pptx
Data Structures and Algorithms presentation.pptxData Structures and Algorithms presentation.pptx
Data Structures and Algorithms presentation.pptx
 
Data Structures and Algorithms presentation.pptx
Data Structures and Algorithms presentation.pptxData Structures and Algorithms presentation.pptx
Data Structures and Algorithms presentation.pptx
 
Programming process and flowchart
Programming process and flowchartProgramming process and flowchart
Programming process and flowchart
 
Project
ProjectProject
Project
 
PCCF UNIT 1.pptx
PCCF UNIT 1.pptxPCCF UNIT 1.pptx
PCCF UNIT 1.pptx
 
Unit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and FlowchartUnit 3.1 Algorithm and Flowchart
Unit 3.1 Algorithm and Flowchart
 
Computer
ComputerComputer
Computer
 
Learn Programming with Livecoding.tv http://goo.gl/tIgO1I
Learn Programming with Livecoding.tv http://goo.gl/tIgO1ILearn Programming with Livecoding.tv http://goo.gl/tIgO1I
Learn Programming with Livecoding.tv http://goo.gl/tIgO1I
 
learn computer science.ppt
learn computer science.pptlearn computer science.ppt
learn computer science.ppt
 
Programación no1
Programación no1Programación no1
Programación no1
 
grade 10 2023.pptx
grade 10 2023.pptxgrade 10 2023.pptx
grade 10 2023.pptx
 
Switch case looping
Switch case loopingSwitch case looping
Switch case looping
 
programming.ppt
programming.pptprogramming.ppt
programming.ppt
 
C and its errors
C and its errorsC and its errors
C and its errors
 
10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechz10th class computer science notes in english by cstechz
10th class computer science notes in english by cstechz
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and development
 
Copy of dti2143/dam31303 chap 1 problem solving and program design
Copy of dti2143/dam31303 chap 1 problem solving and program designCopy of dti2143/dam31303 chap 1 problem solving and program design
Copy of dti2143/dam31303 chap 1 problem solving and program design
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 

Mehr von Ar Kyu Dee

Learning outcome 2 prepare make pcb modules
Learning outcome 2 prepare make pcb modulesLearning outcome 2 prepare make pcb modules
Learning outcome 2 prepare make pcb modulesAr Kyu Dee
 
Learning outcome 1 prepare to assemble electronic products
Learning outcome 1 prepare to assemble electronic productsLearning outcome 1 prepare to assemble electronic products
Learning outcome 1 prepare to assemble electronic productsAr Kyu Dee
 
Understanding the Three Basic Structures
Understanding the Three Basic StructuresUnderstanding the Three Basic Structures
Understanding the Three Basic StructuresAr Kyu Dee
 
Understanding Simple Program Logic
Understanding Simple Program LogicUnderstanding Simple Program Logic
Understanding Simple Program LogicAr Kyu Dee
 
Understanding Computer Systems
Understanding Computer SystemsUnderstanding Computer Systems
Understanding Computer SystemsAr Kyu Dee
 

Mehr von Ar Kyu Dee (7)

Cube
CubeCube
Cube
 
Cuboid
CuboidCuboid
Cuboid
 
Learning outcome 2 prepare make pcb modules
Learning outcome 2 prepare make pcb modulesLearning outcome 2 prepare make pcb modules
Learning outcome 2 prepare make pcb modules
 
Learning outcome 1 prepare to assemble electronic products
Learning outcome 1 prepare to assemble electronic productsLearning outcome 1 prepare to assemble electronic products
Learning outcome 1 prepare to assemble electronic products
 
Understanding the Three Basic Structures
Understanding the Three Basic StructuresUnderstanding the Three Basic Structures
Understanding the Three Basic Structures
 
Understanding Simple Program Logic
Understanding Simple Program LogicUnderstanding Simple Program Logic
Understanding Simple Program Logic
 
Understanding Computer Systems
Understanding Computer SystemsUnderstanding Computer Systems
Understanding Computer Systems
 

Kürzlich hochgeladen

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Kürzlich hochgeladen (20)

The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

Using Pseudocode Statements and Flowchart Symbols

  • 2. Tools in Developing Programs • Pseudocode is an English-like representation of the logical steps it takes to solve a problem. Pseudo is a prefix that means false, and to code a program means to put it in a programming language; therefore, pseudocode simply means false code, or sentences that appear to have been written in a computer programming language but do not necessarily follow all the syntax rules of any specific language. • Flowchart is a pictorial representation of the same thing.
  • 3. Writing Pseudocode The following five statements constitute a pseudocode representation of a number-doubling problem: start input myNumber set myAnswer = myNumber * 2 output myAnswer stop
  • 4. Writing Pseudocode Using pseudocode involves writing down all the steps you will use in a program. Usually, programmers preface their pseudocode with a beginning statement like start and end it with a terminating statement like stop. The statements between start and stop look like English and are indented slightly so that start and stop stand out. Most programmers do not bother with punctuation such as periods at the end of pseudocode statements, although it would not be wrong to use them if you prefer that style. Similarly, there is no need to capitalize the first word in a sentence, although you might choose to do so.
  • 5. Writing Pseudocode Pseudocode is fairly flexible because it is a planning tool, and not the final product. Therefore, for example, you might prefer any of the following: • Instead of start and stop, some pseudocode developers would use other terms such as begin and end. • Instead of writing input myNumber, some developers would write get myNumber or read myNumber. • Instead of writing set myAnswer = myNumber * 2, some developers would write calculate myAnswer = myNumber times 2 or compute myAnswer as myNumber doubled. • Instead of writing output myAnswer, many pseudocode developers would write display myAnswer, print myAnswer, or write myAnswer
  • 6. Writing Pseudocode The point is, the pseudocode statements are instructions to retrieve an original number from an input device and store it in memory where it can be used in a calculation, and then to get the calculated answer from memory and send it to an output device so a person can see it. When you eventually convert your pseudocode to a specific programming language, you do not have such flexibility because specific syntax will be required.
  • 7. Flowcharts Some professional programmers prefer writing pseudocode to drawing flowcharts, because using pseudocode is more similar to writing the final statements in the programming language. Others prefer drawing flowcharts to represent the logical flow, because flowcharts allow programmers to visualize more easily how the program statements will connect. Especially for beginning programmers, flowcharts are an excellent tool to help them visualize how the statements in a program are interrelated.
  • 8. Flowcharts You can draw a flowchart by hand or use software, such as Microsoft Word and Microsoft PowerPoint, that contains flowcharting tools. You can use several other software programs, such as Visio and Visual Logic, specifically to create flowcharts. When you create a flowchart, you draw geometric shapes that contain the individual statements and that are connected with arrows.
  • 9. Flowcharts You use a parallelogram to represent an input symbol, which indicates an input operation. You write an input statement in English inside the parallelogram, as shown in the figure.
  • 10. Flowcharts Arithmetic operation statements are examples of processing. In a flowchart, you use a rectangle as the processing symbol that contains a processing statement, as shown in the figure.
  • 11. Flowcharts To represent an output statement, you use the same symbol as for input statements—the output symbol is a parallelogram, as shown in the figure. Because the parallelogram is used for both input and output, it is often called the input/output symbol or I/O symbol.
  • 12. Flowcharts To show the correct sequence of these statements, you use arrows, or flowlines, to connect the steps. Whenever possible, most of a flowchart should read from top to bottom or from left to right on a page. That’s the way we read English, so when flowcharts follow this convention, they are easier for us to understand.
  • 13. Flowcharts To be complete, a flowchart should include two more elements: terminal symbols, or start/ stop symbols, at each end. Often, you place a word like start or begin in the first terminal symbol and a word like end or stop in the other. The standard terminal symbol is shaped like a racetrack; many programmers refer to this shape as a lozenge, because it resembles the shape of the medication you might use to soothe a sore throat
  • 14. Flowcharts The figure shows a complete flowchart for the program that doubles a number, and the pseudocode for the same problem. You can see from the figure that the flowchart and pseudocode statements are the same— only the presentation format differs.
  • 15. Using a Sentinel Value to End a Program You represent a decision in a flowchart by drawing a decision symbol, which is shaped like a diamond. The diamond usually contains a question, the answer to which is one of two mutually exclusive options—often yes or no. All good computer questions have only two mutually exclusive answers, such as yes and no or true and false.
  • 16. Using a Sentinel Value to End a Program The question to stop the doubling program should be “Is the value of myNumber just entered equal to 0?” or “myNumber = 0?” for short. The complete flowchart will look like the one shown in the figure.
  • 17. Using a Sentinel Value to End a Program One drawback to using 0 to stop a program, of course, is that it won’t work if the user does need to find the double of 0. In that case, some other data- entry value that the user never will need, such as 999 or –1, could be selected to signal that the program should end. A preselected value that stops the execution of a program is often called a dummy value because it does not represent real data, but just a signal to stop. Sometimes, such a value is called a sentinel value because it represents an entry or exit point, like a sentinel who guards a fortress.
  • 18. Using a Sentinel Value to End a Program Not all programs rely on user data entry from a keyboard; many read data from an input device, such as a disk. When organizations store data on a disk or other storage device, they do not commonly use a dummy value to signal the end of the file. Programming languages can recognize the end of data in a file automatically, through a code that is stored at the end of the data. Many programming languages use the term eof (for end of file) to refer to this marker that automatically acts as a sentinel.
  • 19. Using a Sentinel Value to End a Program In the flowchart shown, the eof question is shaded.