In this C program we will Print the Binary Equivalent of a Decimal Number Using Bitwise Operator and then we will print the result on the screen. The Number will be taken from the user.color>
N:Bcolor> This Program is created for upto 8-bit binary number(
i.e: 28-1 = 27 = 0 to 128
). input:
The Number (integers) (i.e. 15,10,128 etc.)output:
The binary equivalent of the decimal number, will be printed on the screen.CODE---->
#include
int main()
{
int n,i,x;
printf(" Please, Enter a Number : ");
scanf("%d",&n);
printf("\n ");
for(i=7;i>=0;i--)
{
x=n&(1i);
if(x==0)
printf("0");
else
printf("1");
}
return 0;
}
color>