0% found this document useful (0 votes)
3 views

02 CS1 Unit 2 - Lesson 2

The document outlines the program development cycle, emphasizing the importance of understanding the problem, planning logic using flowcharts and pseudocode, coding, testing, and maintaining programs. It explains how pseudocode serves as an English-like representation of logical steps and describes flowchart symbols used to visualize program flow. The document concludes with an assessment task for creating a logical solution using both flowchart and pseudocode.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

02 CS1 Unit 2 - Lesson 2

The document outlines the program development cycle, emphasizing the importance of understanding the problem, planning logic using flowcharts and pseudocode, coding, testing, and maintaining programs. It explains how pseudocode serves as an English-like representation of logical steps and describes flowchart symbols used to visualize program flow. The document concludes with an assessment task for creating a logical solution using both flowchart and pseudocode.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

CS 1 – Computer

Programming
Unit 1: Flowchart, Pseudocode, and Logic Formulation
Lesson 2: Program Development Cycle, Pseudocode Statements and Flowchart Symbols
Learning Outcome

• Created a flowchart of the logical


solution

• Created a pseudocode of a logical


solution
Program Development Cycle
Program Development Cycle
•A programmer’s job involves writing instructions,
but a professional programmer usually does not
just sit down at a computer keyboard and start
typing. Programmers also carefully plan on how
to achieve the desired outcome of their programs.
They follow the program development cycle to
achieve their goals.
Program
Development
Cycle
Understanding the Problem
• Professional computer programmers write programs to
satisfy the needs of others, called users or end users.
Understanding the problem may be one of the most
difficult aspects of programming. On any job, the
description of what the user needs may be vague—
worse yet, users may not really know what they want,
and users who think they know frequently change their
minds after seeing sample output. A good programmer
is often part counselor, part detective!
Plan the Logic
• The heart of the programming process lies in
planning the program’s logic. During this phase of
the process, the programmer plans the steps of the
program, deciding what steps to include and how
to order them. You can plan the solution to a
problem in many ways. The two most common
planning tools are flowcharts and pseudocode.
Plan the Logic (Cont.)
• The programmer shouldn’t worry about the syntax
of any particular language at this point, but should
focus on figuring out what sequence of events will
lead from the available input to the desired
output. Planning the logic includes thinking
carefully about all the possible data values a
program might encounter and how you want the
program to handle each scenario.
Coding the Program

•After the logic is developed, only then can the


programmer write the program. Hundreds of
programming languages are available.
Programmers choose particular languages
because some have built-in capabilities that
make them more efficient than others at
handling certain types of operations.
Testing the Program
• A program that is free of syntax errors is not
necessarily free of logical errors. A logical error
results when you use a syntactically correct
statement but use the wrong one for the current
context. Once a program is free of syntax errors,
the programmer can test it—that is, execute it with
some sample data to see whether the results are
logically correct.
Putting the Program into Production
• Once the program is tested adequately, it is ready
for the organization to use. Putting the program
into production might mean simply running the
program once, if it was written to satisfy a user’s
request for a special list. However, the process
might take months if the program will be run on a
regular basis, or if it is one of a large system of
programs being developed.
Maintaining the Program
• After programs are put into production, making
necessary changes is called maintenance.
Maintenance can be required for many reasons:
new tax rates are legislated, the format of an input
file is altered, or the end user requires additional
information not included in the original output
specifications, to name a few.
Pseudocode Statements
Pseudocode
• 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.
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.
Sample Pseudocode

start
input myNumber
set myAnswer = myNumber * 2
output myAnswer
stop
Pseudocode is fairly flexible because it is a planning
tool, and not the final product. Therefore, for
example, we might prefer any of the following:

• Instead of start and stop, some pseudocode


developers would use the terms 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.
Drawing Flowcharts
• Other developers 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.
Flowchart Symbols

Terminal Symbol Decision Symbol

Input/Output
Flowlines
Symbol

Process Symbol
Terminal Symbols

•Often, we 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. Terminal
Symbols signals the start and the end of the
program.
Input/Output Symbol

•We use a parallelogram to represent an input


symbol, which indicates an input operation.
We write an input statement in English inside
the parallelogram. To represent an output
statement, we use the same symbol as for
input statements—the output symbol is a
parallelogram.
Process Symbol

•Arithmetic operation statements are examples


of processing. In a flowchart, we use a
rectangle as the processing symbol that
contains a processing statement.
Decision Symbol
• We 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.
Flowlines
• To show the correct sequence of statements in the
flowchart, we 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.
Sample Flowchart
Flowchart and Pseudocode
Assessment Tasks

• Look for a computing problem and


create a logical solution. Show your
logical solution by means of
Flowchart and Pseudocode.
End

You might also like