The
while
is attached to the
do
at the top of the block, and it's one of the three types of loops that C supports:
for
,
while
, and
do ... while
The
do ... while
statement is very similar to the
while
loop, except that the loop body is always executed once, because the loop / don't loop condition is only checked after the body, not before.
The condition here is just
k
and because C doesn't have boolean operators, a value of zero is always taken as "false" and any non-zero value is always taken as "true".
so your code:
do
{
...
} while (k);
is the same as:
do
{
...
} while (k != 0);