i wrote this code yesterday and i traced it myself but the problem is the array doesn't store any number in it and the output was like this :
//convert from decimal to binary
#include<iostream>
using namespace std ;
void main(){
int n,c=0,*pointer,temp=0,r,i,y ;
cout<<"Enter number\n";
cin>>n;
y=n ;
for(;;){
if(n==0)
{break ;}
n=n/2 ;
c++ ;
}
pointer=new int[c] ;
for(i=0;i<c;i++){
temp=y ;
y=y/2 ;
r=temp%2 ;
pointer[i]=r ;
}
cout<<"the binary number is :";
for(i=c-1;i<0;i--)
cout<<pointer[i];
cout<<endl;
system("pause");
}