Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main()
- {
- int k, n;
- int binary[100];
- printf("Enter the value in decimal n ");
- scanf("%d", &k);
- n = (log(k * 1.0) / log(2 * 1.0)) + 1 ; //total no. of binary bits in this decimal
- for (int i = n; i > 0; i--)
- {
- binary[i] = k % 2;
- k /= 2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement