Changing decimal number to its binary equivalent

Changing decimal number to its binary equivalent

Here is bit level solution to change binary equivalent

#include 

/*
 * Printing binary version representation of number
 *
 * Kaleb Woldeareagy <contactkaleb@gmail.com>
 */

void to_binary(unsigned int x);

void main()
{
    unsigned int y=17;
    to_binary(y);
}

void to_binary(unsigned int x)
{
    if (!x|00)
    {
        printf("0");
    }
    else
    {
        int i=0;
        int store[8]; //stack could be used here best
        while (x!=0)
        {
            store[i++]=x&01;
            x>>=1;
        }

        while (i>0)
        {
            printf("%i", store[--i]);
        }
    }
}

See how you would solve these known algorithm problems

Find the pairs that makes K Complementary in the given array java solution

Implementing tokenizer and adding tokens to the linked list

Find the first occurence of number in the sorted array

binary tree problems with solution

Find K Complementary numbers from array Java implementation

Check if there are three numbers a, b, c giving a total T from array A

testing k complementary pairs algorithm with junit

Array reversal in Recurrsion

Java solution for checking anagram strings – tell if phrases are anagrams

Check if two strings are anagrams or not

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*