This code for finding the binary representation of a number works if I type a number of 3 digits but if i type a number like 3427 , it doesn't ...
I use Dev-++ , I have tried to debug and apparently the problem is on the line after while , perhaps the ze[u] .
Code:
#include <iostream>
using namespace std;
int main()
{
long x,z,n,y=0,u;
long ze[y];
cout<<"write an integer : ";
cin>>x;
for(n=x;n>0;n/=2){
z=n%2;
cout<<z<<',';ze[y]={z}; y++;
}
cout<<" The last digit is the first digit\n of the binary representation of "<<x<<endl<<endl;
cout<<" Now , the right order : "<<endl;
u=y-1;
while (u>=0){
cout<<ze[u]<<",";u--;
}
char zs;cin>>zs;
}