Okay i'm not that great at C++ as you will see from how far i got until i hit a wall.
The problem is this
Allows the user to input a series of 0's and 1's which will be stored as an array representing a binary word. Input should stop when something other than a 0 or a 1 is input by the user and display the decimal equivalent.
To convert i think i got the concept but i just cant seem to implement it
take each number individually and multiply it by 2 to the power of the placement of the number - 1.
so you start with the number far left and move right:
(1*2^4)+(1*2^3)+(0*2^2)+(1*2^1)+(0*2^0) = 26
so i had a crack at it
using namespace std;
void main ()
char binary ,*p; //array size declared
cout<<"Enter binary input(1's & 0's):";
Binary Input is:"<<binary<<endl; //display array output
for (power=strlen(binary)-1;power>-1; power--) //calculates the power
cout<<power<<endl; //test output
i'm sure there need to be another loop to retrieve the array values. then its a simple task of calculating the output
sum + = binary[i] * pow(2, power)
This is probably easy but i have been working on my other units and made the mistake of assuming it was easier then it looked
thanks in advance.