Sunday, 27 January 2013

#include <stdio.h>

int main()
{
    int n;
    int i = 0;
    int binary[32];
    int lb;

    printf("Number : ");
    scanf("%d", &n);
   
    while(i<0)
        binary[i++] = 0;
   
    while(n > 0)
    {
        for( i = 0; i<32; i++ )
        {   
            lb = n % 2;
            binary[i] = lb;
            n = n >> 1;
        }
    }
   
    i = 31;
    while(i>=0)
        printf("%d", binary[i--]);
   
    return 0;
}

Get Ebooks delivered to your email id

Comments

Subscribe to our channel

Facebook

Powered by Blogger.

Home | Contact Us | DMCA | Terms of Service | Privacy | Advertise

Maven Scientists