Hello people, Again, trying to create a program in C to help figuring what the equivalent binary-number to a given number is. I had no idea what to do first, I developed a little simple code for it. But the problem is that I had to put some improvisations into it AS code is (READ BACKWARDS). So regarding this, the code isn't really complete. Here's the code I came up with ..
#include <stdio.h>
void main()
{
int x,n;
printf("This program will help you find the equivalent binary-number to a given number \n");
printf("Enter number :");
scanf("%d",&n);
printf("The binary number to this number is(Read backwards) :");
for (;;n/=2)
{
x=n/2;
if (x!=0) printf("%d",n%2);
else {printf("%d\n",n%2); break;}
}
}
Now the equivalent binary-number to 8 is 1000 and the program shows it backwards like 0001 and I have absolutely no idea how to to make it right. Any thoughts?