Sunday, April 29, 2018

How to convert Decimal to Binary_Most_Basic_(Number_System_Part_1)

#include<stdio.h>
main()
{
    int n,rem,bin=0,k=1;
    printf("Enter a decimal number ");
    scanf("%d",&n);
    while(n!=0)
    {
        rem=n%2;
        bin=bin+rem*k;
        k=k*10;
        n=n/2;

    }
    printf("Binary = %d\n",bin);

}

No comments:

Post a Comment