C Program to Convert any Decimal Number to Binary Number



#include<stdio.h>
#include<conio.h>

int main( )
{
long int d,b;
long int i=0,a[20],j;
clrscr( );

printf("Enter Decimal Number: ");
scanf("%ld",&d);

while(d>0)
{
  a[i]=d%2;
  d=d/2;
  i++;
}

printf("Its Equivalent Binary Number is : ");
for(j=i-1; j>=0; j--)
printf("%ld",a[j]);
getch( );
}

No comments

Post your comments

Powered by Blogger.