Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Do...while Loop | Introduction to Program Flow
C++ Introduction

Do...while LoopDo...while Loop

Unlike a while loop, which may never execute, a do...while loop is guaranteed to execute at least once. Structure of do…while loop:

Note

The line containing the while part ends with a semicolon (;)

Now let's compare the while and do…while loops.

The while loop:

cpp

main.cpp

The do...while loop:

cpp

main.cpp

The do...while loop executed one time when the while loop would never have executed.

Tudo estava claro?

Seção 4. Capítulo 5
course content

Conteúdo do Curso

C++ Introduction

Do...while LoopDo...while Loop

Unlike a while loop, which may never execute, a do...while loop is guaranteed to execute at least once. Structure of do…while loop:

Note

The line containing the while part ends with a semicolon (;)

Now let's compare the while and do…while loops.

The while loop:

cpp

main.cpp

The do...while loop:

cpp

main.cpp

The do...while loop executed one time when the while loop would never have executed.

Tudo estava claro?

Seção 4. Capítulo 5
some-alt