#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int no,r,sum=0,i=0;
clrscr();
printf(“\nenter the number\n”);
scanf(“%d”,&no);
while(no>0)
{
r=no%2;
sum=sum+pow(10,i)*r;
no=no/2;
i++;
}
printf(“\nthe binary value is %d”,sum);
getch();
}
Output:
enter the number
8
the binary value is 1000
No comments:
Post a Comment