Guest User

Untitled

a guest
Oct 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     long long decimalNumber;
  6.     int resultArray[60]={0},index=0;
  7.  
  8.     scanf("%lld",&decimalNumber);
  9.    
  10.     if(decimalNumber == 0)
  11.     {
  12.         printf("0");
  13.         return 0;
  14.     }
  15.  
  16.     while(decimalNumber > 0)
  17.     {
  18.         if(decimalNumber % 2 == 0)
  19.         {
  20.             resultArray[index]=0;
  21.         }
  22.         else
  23.         {
  24.             resultArray[index]=1;      
  25.         }
  26.         decimalNumber /= 2;
  27.         index++;
  28.     }
  29.     index--;
  30.     for(;index>=0;index--)
  31.         printf("%d",resultArray[index]);
  32.    
  33.     return 0;
  34. }
Add Comment
Please, Sign In to add comment