Кіріспе
Бағдарламалауды басқару ағыны мәлімдемесі Көптеген компьютерлік бағдарламалау тілдерінде do while циклы – бұл код блогын орындайтын және содан кейін берілген логикалық шартқа байланысты блокты қайталайтын немесе циклден шығатын бақылау ағыны мәлімдемесі. Do while конструкциясы операция символы мен шарттан тұрады. Бірінші кезекте блок ішіндегі код орындалады. Содан кейін шарт бағаланады. Егер шарт тура болса, блок ішіндегі код тағы да орындалады. Бұл шарт жалған болғанға дейін қайталанады. Do while циклдері код блогы орындалғаннан кейін шартты тексереді. Бұл бақылау құрылымын сынақтан кейінгі цикл деп атауға болады. Бұл do while циклы шығу шарты бойынша жұмыс істейтін цикл екенін білдіреді. Алайда, while циклы блоктағы кодты орындау алдында шартты тексереді. Бұл код әрқашан бірінші болып орындалады, содан кейін өрнек немесе сынақ шарты бағаланады. Бұл процесс өрнек тура болғанша қайталанады. Егер өрнек жалған болса, цикл аяқталады. While циклы кодты орындау үшін қажетті шарт ретінде мәлімдеменің дұрыстығын белгілейді. Do while циклы шарт бұдан былай тура болмайынша, операцияның үздіксіз орындалуын қамтамасыз етеді. Шарттың әрқашан тура бағалануы мүмкін және кейде қажет. Бұл шексіз циклді құрайды. Егер шексіз цикл қасақана жасалса, әдетте циклді тоқтатуға мүмкіндік беретін басқа басқару құрылымы болады. Мысалы, break операторы шексіз циклді тоқтатуға мүмкіндік береді. Кейбір тілдерде осы цикл түрі үшін басқа атаулар қолданылуы мүмкін. Мысалы, Pascal және Lua тілдерінде «қайталау…шартқа дейін» циклы бар, ол бақылау өрнегі тура болғанға дейін жалғасады, содан кейін аяқталады. Керісінше, «while» циклы бақылау өрнегі тура болғанда жұмыс істейді және өрнек жалған болғанда аяқталады.
In many computer programming languages, a do while loop is a control flow statement that executes a block of code and then either repeats the block or exits the loop depending on a given boolean condition. The do while construct consists of a process symbol and a condition. First the code within the block is executed. Then the condition is evaluated. If the condition is true the code within the block is executed again. This repeats until the condition becomes false. Do while loops check the condition after the block of code is executed. This control structure can be known as a post test loop. This means the do while loop is an exit condition loop. However a while loop will test the condition before the code within the block is executed. This means that the code is always executed first and then the expression or test condition is evaluated. This process is repeated as long as the expression evaluates to true. If the expression is false the loop terminates. A while loop sets the truth of a statement as a necessary condition for the code's execution. A do while loop provides for the action's ongoing execution until the condition is no longer true. It is possible and sometimes desirable for the condition to always evaluate to be true. This creates an infinite loop. When an infinite loop is created intentionally there is usually another control structure that allows termination of the loop. For example, a break statement would allow termination of an infinite loop. Some languages may use a different naming convention for this type of loop. For example, the Pascal and Lua languages have a "repeat until" loop, which continues to run until the control expression is true and then terminates. In contrast a "while" loop runs while the control expression is true and terminates once the expression becomes false.
Do while циклдарын көрсету
Бұл мысал бағдарламалар әр тілдің do while циклының синтаксисін қолданып, 5 санының факториалын есептейді.