Program in c to convert decimal no.
into corresponding binary number
#include<stdio.h>
#include<conio.h>
void main()
{
int dec,d,c=1;
long int bn=0;
clrscr();
printf("Enter decimal number:");
scanf("%d",&dec);
while(dec!=0)
{
d=dec%2;
dec=dec/2;
bn=bn+c*d;
c=c*10;
}
printf("Binary no. of given decimal no.
is:");
printf("%ld",bn);
getch();
}
output:
enter decimal number: 7
Binary no. of given
decimal no. is:111
No comments:
Post a Comment