Hi I have been giving an assignment for my programming in C class and a question im stuck on is this. 
"Prompts the user to enter a valid integer between 0 and
2147483647 inclusive, and then displays the converted
value as a 32-bit binary number with 1 space separating
each 8-bits in the binary value. If an invalid number
is entered (i.e < 0 or > 2147483647)"
it wants me to output the binary in 32 bit format such as 00000000 00000000 00000000 00011111 =31 with all of the 0's and spacing between each set of 8 and I am stuck. 

```
 printf("enter a valid integer between 0 and 2147483647\n");
                 scanf("%d",&decimal);
                 fflush(stdin);
                 if (decimal>0||decimal<2147483647)
                   {while (decimal!=0)
                   {
                          remainder = decimal%2;
                          binary=(remainder*place)+binary;
                          decimal=decimal/2;
                          place=place*10;}
                   printf("%d",binary);}

```

this kinda works until the input is over 1000 then its gets messed up. unsure why as well.