Header Ads Widget

Responsive Advertisement

Decimal To Bainary

 


#include <stdio.h>

int main()
{
    int n,rem,i;
    int arr[100];
    printf("Enter the number :");
    scanf("%d",&n);
    while (n) {
        rem = n%2;
        n=n/2;
        arr[i] = rem;
        i++;
    }
    // For Reverse arr[i]
    for(int j = i-1; j>=0 ; j--) {

        printf("%d ",arr[j]);
    }

    return 0;
}


Post a Comment

0 Comments