Needing help for programming an algorithm in c++, about conversion from decimal to binary. Here's my deal, but it's wrong. Anyone for helping me?
include <iostream>
#include <math.h>
using namespace std;
int main ()
{
int a[10], x, y, i;
for (i=0; i<=0; i++)
cout<<"x= ";
cin>>x;
do {
y=x/2;
a[i]=x%2;
i=i+1;
}
while (x>=2);
cout<<"binary= "<<a[i]<<endl;
return 0;