A Base 2 to Base 10 converter programmmed in C++. This program will take in a number in Base 10 and convert that number to Base 2. A very helpful tool if you are beginning to learn how base 2 works, if you are not familiar with base 2 see this section first. how base 2 works
//full working program
#include <iostream>
using namespace std;
int main()
{
int i=-1,k=0,z,array_1[100],array_2[100];
double y;
cin>>array_2[0];
while (y != 0)
{
i++;
array_1[i]=array_2[k]%2;
if (array_1[i]==1)
{
y = (array_2[k]/2.0)-.5;
}
if (array_1[i]==0)
{
y = (array_2[k]/2.0);
}
k++;
array_2[k]=y;
}
cout<<array_2[0]<<" converted to base 2 is\n"<<endl;
for(k=i; k>=0; k--)
{
cout<<array_1[k];
}
return 0;
}