OUTPUT (after running): Enter a number:
12345
12345 is not a binary number.
Enter a number:
11001011
11001011 is a binary number.
The do-while Loop The general syntax of a do-while loop is as follows:
do
{
statement(s);
} while (test-condition);
The do-while statement evaluates the test condition at the end of the loop. This loop guarantees
that the loop will be executed at least once.
Whereas a loop is called a
pretest loop or entry- controlled loop, a do-while loop is known as a
posttest loop or exit-controlled loop. A loop that
uses another loop is called a
nested loop. Any type of loop may be used inside another loop. The rules for
nested loops are as follows: Rule 1: An inner loop goes through all of its iterations for each iteration of an outer loop.