Convert the decimal number to binary number
/*WAP to convert
the decimal number to binary number*/
#include<stdio.h>
#include<conio.h>
void main()
{
int
dec,bin=0,d,t=1;
clrscr();
printf("enter
the decimal number:");
scanf("%d",&dec);
while(dec!=0)
{
d=dec%2;
bin=bin+(d*t);
t=t*10;
dec=dec/2;
}
printf("the
binary number is %d",bin);
getch();
}
OUTPUT:
enter the decimal
number:15
the binary number
is 1111
No comments:
Post a Comment