Vous êtes sur la page 1sur 24

SimpleSequence

ControlStructure
ToolsforStructuredand
ObjectOrientedDesign

Objectives
Defineanalgorithm
Namethecharacteristicsofanalgorithm
Namethefourparts,inorder,ofadatahierarchy
Identify,anduseinprogramflowchartandsystem
flowchart
Identify,anduseinprogramdesign,theterminal
interrupt,generalI/O,andprocessprogram
flowchartingsymbol
Identify,anduseinprogramdesign,variables,
constants,andassignmentstatements.

Objective(continued)
Distinguishbetweeninputandoutput,and
explainwhyinputandoutputstepsare
neededinprogramdesign
Performaprocedureexecutionofasimple
algorithm

Algorithm?
What is an algorithm? (alg&-rith-&m) (n.)
A formula or set of steps for solving a particular
problem.
To be an algorithm, a set of rules must be
unambiguous and have a clear stopping point.
Algorithms can be expressed in any language,
from natural languages like English or French to
programming languages like FORTRAN.

What are the characteristics of an algorithm?

UnderstandingUnstructuredSpaghetti
Code

Thepopularname
forsnarledprogram
statementsis
spaghetticode
Thereasonforthe
nameshouldbe
obviousthecode
isasconfusingto
readasfollowing
onenoodlethrough
aplateofspaghetti

UnderstandingtheSimpleSequence
Structures

Astructureisabasicunit
ofprogramminglogic;
eachstructureisa
sequence,selection,or
loop
Thefirstofthese
structuresisasequence,
asshowninFigure23
Withasequencestructure,
youperformanactionor
event,andthenyou
performthenextaction,in
order

WakeupAlgorithm

UnderstandingtheDataHierarchy
Whendataisstoredforuseoncomputersystems,
itisoftenstoredinadatahierarchy,wherethe
smallestusableunitofdataisthecharacter
Charactersareletters,numbers,andspecial
symbols,suchasA,7,and$
Afieldisasingledataitem,suchaslastName,
streetAddress, or annualSalary

UnderstandingtheDataHierarchy
(continued)
Recordsaregroupsoffieldsthatgotogetherfor
somelogicalreason
Filesaregroupsofrecordsthatgotogetherfor
somelogicalreason
Adatabaseholdsagroupoffiles,oftencalled
tables,thattogetherservetheinformationneedsof
anorganization
Databasesoftwareestablishesandmaintains
relationshipsbetweenfieldsinthesetables,sothat
userscanwritequestionscalledqueries

DataHierarchy

Systemvs.Program
Flowchart
SystemFlowchart
Illustratingthebasicinputs,processes,and
outputsofthecomputersystem.

ProgramFlowchart
Stepbysteplogicoftheprogram

SystemFlowchart

ProgramFlowchart

Systemvs.Program

FlowchartForm

UsingandNamingVariables
Variablesarememorylocations,whosecontents
canvaryordifferovertime
Sometimes,inputNumbercanholda2and
calculatedAnswerwillholda4;atother
times,inputNumbercanholda6and
calculatedAnswerwillholda12
Avariablenameisalsocalledanidentifier

UsingandNamingVariables
(continued)
Variablenamesusedherefollowonlytworules:
1. Mustbeoneword
2. Havesomeappropriatemeaning

AssigningValuestoVariables
Whenyoucreateaflowchartorpseudocodefora
programthatdoublesnumbers,youcaninclude
thestatementcomputecaclulatedAnswer
as inputNumber times 2
Thisstatementincorporatestwoactions:
First,thecomputercomputesthearithmeticvalue
ofinputNumber times 2
Second,thecomputedvalueisstoredinthe
calculatedAnswermemorylocation

AssigningValuestoVariables
(continued)
Mostprogramminglanguagesallowashorthand
expressionforassignmentstatementssuchas
computecaculatedAnswer as
inputNumber times 2
Theshorthandtakestheform
calculatedAnswer = inputNumber *
2
Theequalsignistheassignmentoperator,which
alwaysrequiresthenameofamemorylocationon
itsleftsidethelocationwheretheresultwillbe
stored

UnderstandingDataTypes
Computersdealwithtwobasictypesofdata
characterandnumeric
Whenyouuseaspecificnumericvalue,suchas
43,withinaprogram,youwriteitusingthedigits
andnoquotationmarks
Aspecificnumericvalueisoftencalledanumeric
constantbecauseitdoesnotchangea43always
hasthevalue43
Whenyouuseaspecificcharactervalue,orstring
ofcharacters,suchasChrisyouenclosethe
string,orcharacterconstant,withinquotation
marks

UnderstandingDataTypes(continued)
Mostcomputerlanguagesallowatleasttwo
distincttypesofvariables:
Oneholdsanumber,oftencalledanumeric
variable
Othersholdlettersofthealphabetandvarious
specialcharacterssuchaspunctuationmarks,and
arecalledcharacter,text,orstringvariables,
dependingonthelanguagebeingused

UnderstandingDataTypes(continued)
Somelanguagesallowforseveraltypesof
numericdata
LanguagessuchasPascal,C++,C#,andJava
distinguishbetweeninteger(wholenumber)
numericvariablesandfloatingpoint(fractional)
numericvariablescontainingadecimalpoint

FlowchartTemplate

GraphicalUserInterface
GUI

Vous aimerez peut-être aussi