Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
606 B
2
Indexable
Never
#include<stdio.h>
void binary(int a)
{
    int number[100];
    int index=0;
    while(a==0)
    {
        printf("Binary : 0\n");
    }
    while(a>0)
    {
        number[index]=a%2;
        a=a/2;
        index++;
    }
    printf("After conversion : ");
    for(int i=index-1;i>=0;i--)
    {
        if(number[i]==0){
        printf("%d",number[i]);
        }
        if(number[i]==1)
        {
            printf("*");
        }
    }
    printf("\n");
}


int main()
{
    int a;
    printf("enter a number : ");
    scanf("%d",&a);
    binary(a);
    return 0;
}
Leave a Comment