I'm confused by this problem. Can someone break it down for me?

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. Much as in the decimal number system, where the rightmost digit has a positional value of 1, the next digit left has a positional value of 10, then 100, then 1000, and so on, 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, or 13.

Please explain what the problem is asking. I dont know where to start with this one. What is the program supposed to do step by step? I want to write the code myself but before I do, I need to understand which steps the program will need in order to perform.
The program should prompt the user to enter a number.
This number should be in binary, so the user should only enter 0's and 1's.
Then your program must take this binary number and convert it to a decimal.
The program should output this converted number to the screen.
Get the input as a string of ones and zeros, e.g. "1101".

It would be sensible to verify that the input is valid, that is, no other characters other than '1' or '0' were entered.

Next, you need to convert the string of characters into a number (an integer type). This part, while fairly straightforward, will take a few lines of code.

As an integer, you can then easily print the decimal value. (just cout << n;).

Lastly, you convert your integer into binary digits. The method is to repeatedly divide it by 2. The remainder will be either 1 or 0, which gives the required binary digit. The number will get smaller each time until it is zero. Then you can stop.

Thank you for breaking it down for me. Now, I understand what the program should do. I searched how to convert binary numbers to decimal and vice versa. Based on what I understood 010110 would be converted to 22. I'm trying to write the code for the program to do it, but I'm realizing I have no idea how to program each step. Any advice or more suggestions?
Topic archived. No new replies allowed.