Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Print Binary Equivalent of a Decimal Number Using Bitwise Operator in C-Language




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;
}





Don't just read, write it, run it.....color>

RESULT:color>





This post first appeared on ProgramJoy.blogspot.com, please read the originial post: here

Share the post

Print Binary Equivalent of a Decimal Number Using Bitwise Operator in C-Language

×

Subscribe to Programjoy.blogspot.com

Get updates delivered right to your inbox!

Thank you for your subscription

×