How it works...

You will be prompted to enter a decimal number. The number you enter is assigned to the num variable. The value entered in the num variable is temporarily assigned to another variable, temp. A while loop is set to execute until the value of num becomes 0. Apply the logical AND operation to isolate each binary digit of the number. For example, if the value entered in variable num is 13, then, internally, it will be stored in a binary format as follows:

Figure 16.2

Now, the least significant bit is isolated by applying the AND operation. That is, the binary digits of 13 are ANDed with 1 as follows. The ANDed means the AND operation ...

Get Practical C Programming 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.