// calc_bin_rep_solution1.c - First solution for the example
//                            that calculates the binary
//                            representation of a number

#include <stdio.h>

// function declarations

int readInt();
void outputBinRep(int num);


//------------------------------------------------------------

int main()
{
  printf("Please enter a number: ");
  outputBinRep(readInt());
  printf("\n");
  return(0);
}

//------------------------------------------------------------

int readInt()
{
  int input = 0;
  scanf("%d",&input);
  return(input);
}

//------------------------------------------------------------
void outputBinRep(int num)
{
  unsigned bitmask = 0x1 << ((sizeof(int) * 8) - 1);
  while(bitmask)
  {
    printf("%c",(num & bitmask) ? '1' : '0');
    bitmask >>= 1;
  }
}
