Вы находитесь на странице: 1из 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

Вам также может понравиться