I'm looking to perform the decimal to binary conversion...how do I reverse the binary code stored in str[i], marked in asterisk so that I get the correct output ??
#include <stdio.h>
#include <string.h>
void main()
{
int a, b, c, i;
int str[10];
printf("Enter an integer of your choice : ");
scanf("%d", &a);
b=a;
while (a!=0)
{
for (i=0;a>i;i++)
{
c=a%2;
str[i]=c; // ***** the binary value is stored here
printf("%d", str[i]);
a=a/2;
i++;
}
}
}