I dont know what is wrong it is supposed to convert decimal to binary!
Can I declare Arrays whose number of elements is variable?
How?
This program already output
the binary equivalent but it has extra numbers
#include
void main ()
{
int num,xnum,dgts,counter;
cout<<"Enter Number"<
cin>>num;
if(num<=1)
cout<
else
{
xnum=num;
dgts=0;
while(xnum>=1)
{
xnum=xnum/2;
dgts+=1;
}
int bnr[50];
for (counter=0;counter
{
bnr[counter]=num%2;
num=num/2;
}
cout<
while(dgts>=0)
{
dgts=dgts-1;
cout<
}
}
}
2007-03-05
18:00:08
·
2 answers
·
asked by
topher09
2
in
Computers & Internet
➔ Programming & Design