Saturday, November 5, 2011

Decimal number to Binary in C language


#include<stdio.h>
#include<conio.h>
void main()
{
int n,k=1,i,j,r;
clrscr();
printf("Please enter the number:");
scanf("%d",&n);
printf("\n\nBinary equivalent::");
for(i=15;i>=0;i--)
{
j=k<<i;
r=n&j;
if(r>0)
printf("1");
else
printf("0");
}
getch();

}

0 comments:

Post a Comment

You are most welcome for making comments here. I will consider your view and will reply you soon.