Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. int main()
  2. {
  3.  
  4. int k, n;
  5. int binary[100];
  6. printf("Enter the value in decimal n ");
  7. scanf("%d", &k);
  8. n = (log(k * 1.0) / log(2 * 1.0)) + 1 ; //total no. of binary bits in this decimal
  9.  
  10. for (int i = n; i > 0; i--)
  11. {
  12. binary[i] = k % 2;
  13. k /= 2;
  14. }
  15.  
  16. return 0;
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement