Name
do statement — Test-at-bottom loop statement
Synopsis
statement := do statement while ( expression ) ;
The do
statement is a loop
that executes statement, then
tests expression. The loop
iterates while expression is true
and ends if expression is false.
The loop body always executes at least once.
Example
do
{
cout << "Number: ";
if (cin >> num)
data.push_back(num);
} while(cin);
See Also
break
, continue
, expression, for
, statement, while
, Chapter
4
Get C++ In a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.