#include <stdio.h>
#include <conio.h>
void main()
{
int a,b,no[100],i,c,n=0;
clrscr();
printf("\nEnter Decimal Number: ");
scanf("%d",&b);
if(b>0)
{
a=b;
printf("\nThe binary equivalant of decimal number is: 0");
}
else
{
a=-b;
printf("\nThe binary equivalant of decimal number is: 1") ;
}
for(i=0;a!=0;++i)
{
c=a%2;
no[i]=c;
a=a/2;
++n;
}
for(i=n-1;i>=0;--i)
{
printf("%d",no[i]);
}
getch();
}
#include <conio.h>
void main()
{
int a,b,no[100],i,c,n=0;
clrscr();
printf("\nEnter Decimal Number: ");
scanf("%d",&b);
if(b>0)
{
a=b;
printf("\nThe binary equivalant of decimal number is: 0");
}
else
{
a=-b;
printf("\nThe binary equivalant of decimal number is: 1") ;
}
for(i=0;a!=0;++i)
{
c=a%2;
no[i]=c;
a=a/2;
++n;
}
for(i=n-1;i>=0;--i)
{
printf("%d",no[i]);
}
getch();
}
No comments:
Post a Comment