Hi i am writing a program to convert a user entered integer number into its binary representation, the aim is to repeatedly ask the user to enter a value then output the number in binary and when 9999 is entered end program, i've managed to make it work with positive integers so far only it displays them backwards. I've read i need to use a shift operator to move the mask across 1 bit each time for this calculation but i cant seem to get it to work, at the moment it doesnt seem to make a difference with or without it. Any ideas please?
Thanks
{
int num, result, remainder;
int i = 1, z = 0;
int mask = 1000000;
while (i = 1){
//Request user input
printf("\nEnter integer value:");
scanf("%d",&num);
//calculation
if (num != 9999){
result = num / 2;
remainder = num % 2;
//while (result != 0)
while (z < 32)
{
if (num & mask !=0)
printf("1");
else
printf("0");
(mask >> 1);
num = result;
result = num / 2;
remainder = num % 2;
z++;
}
z=0;
//printf("%d\n",mask);
}
else break;
}