Vous êtes sur la page 1sur 14

DOUNTIL

ToolsforStructuredandObject
OrientedDesign

Objectives
Indentify,anduseinprogramdesign,the
DOUNTILcontrolStructure
Distinguishbetweenthelogicofa
DOWHILEpatternandthelogicofa
DOUNTILpattern.

UsingtheDoUntilLoop
Whenyouuseeitherawhileoraforloop,thebody
oftheloopmayneverexecute
Whenyouwanttoensurethataloopsbodyexecutesat
leastonetime,youcanuseado untilloop
Inado untilloop,theloopcontrolvariableis
evaluatedaftertheloopbodyexecutes
Therefore,thebodyalwaysexecutesatleastonetime

dountilLoopfor
ProducingOneExtraLabel

PrintingOneLabel,
ThenPrintingEnough
toCoverProduction

Recognizingthe
CharacteristicsSharedbyAllLoops
Allstructuredloopssharethesecharacteristics:
Theloopcontrollingquestionprovideseitherentrytoor
exitfromtherepeatingstructure
Theloopcontrollingquestionsprovidetheonlyentryto
orexitfromtherepeatingstructure

Youshouldalsonoticethedifferencebetween
unstructuredloopsandthestructureddo until
andwhileloops

DOUNTILExample

DOUNTILExample

DOUNTILExample
Pseudocode

DOUNTILExample

DOUNTILExample

DOUNTILExamples

DOWHILEvs.DOUNTIL

DOWHILEvs.DOUNTIL

Vous aimerez peut-être aussi