Question: C++ Program 3. Input an integer containing only 0s and 1s (i.e., a binary integer) and print its decimal equivalent. Use the modulus and division

C++ ProgramC++ Program 3. Input an integer containing only 0s and 1s (i.e.,

3. Input an integer containing only 0s and 1s (i.e., a "binary" integer) and print its decimal equivalent. Use the modulus and division operators to pick off the "binary" number's digits one at a time from right to left. In the binary number system the rightmost digit has a positional value of 1, the next digit left has a positional value of 2, then 4, then 8, and so on. Thus the decimal number 234 can be interpreted as 2 100+3 10+4 1. The decimal equivalent of binary 1101 is 1'1+0' 2 1'4 1 8 or 1 +0+4+8 which is 13. You can find if the least significant digit is O or 1 by using modulo 10 and looking at the remainder. You can get rid of the least significant digit (making 1101 into 110) by dividing the number by 10

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!