C program to convert decimal to Binary

 

#include<stdio.h>
#include<stdlib.h>
int main(){
system("clear");
int decimal=0,arr[50]={0},remainder=0;
printf("Enter the Decimal Digit :");
scanf("%d",&decimal);

static int i;
for(i=0;i<=50;i++)
{
if(decimal>=2)
{
remainder=decimal%2;
arr[i]=remainder;
decimal=decimal/2;
}
else{
arr[i]=decimal;
break;
}

}
for(i;i>=0;i--){
printf("%d",arr[i]);
}





}

Popular posts from this blog

C program to Convert Decimal to Hexadecimal

C Program to Add two Matrix