Monday, April 30, 2018

How to convert Decimal to Binary using Array Number System Part 3

#include<stdio.h>
main()
{
    int n,i=0,j,base=2;
    int bin[100];
    scanf("%d",&n);
    while(n!=0)
    {
        bin[i++]=n%base;
        n=n/base;
    }
    for(j=i-1;j>=0;j--){
        printf("%d",bin[j]);
    }
}

No comments:

Post a Comment