Here what happens is in convert function my j turns out to be 1244860..which i got to know by debugger. Before going in for loop;its value is 0, in for loop value of i-1 is 3...but value of j randomly becomes 1224860.
Hows that happening?
I did the program in Microsoft Visual Studio C++ 6.0
#include<stdio.h>
conv(int d1,int d2)
{
int rem=0,qut=1,i=0,j=0;
int store[20]={0};
while(qut!=0)
{
rem=d1%2;
qut=d1/2;
d1=qut;
store[i]=rem;
i++;
}
for(j=i-1;j>0,i>0;j--,i--)
{
printf("\n%d",store[i]);
}
}
void main()
{
int no1=0,no2=0;
printf("\nEnter first decimal no.\n");
scanf("\n%d",&no1);
printf("\nEnter second decimal no.\n");
scanf("\n%d",&no2);
conv(no1,no2);
}