Showing posts with label BINARY FORM. Show all posts
Showing posts with label BINARY FORM. Show all posts

Thursday, 15 November 2012

Program to calculate binary equivalent of any given number.


#include<stdio.h>
main()
{
   int n=0,i=0,j=0;
   int a[31];
   printf("\nEnter the number \n");
   scanf("%d",&n);
   for(i=0;i<32;i++)
    {
      a[i]=n%2;
      n=n/2;
     }
    for(i=31;i>=0;i--)
    {
   printf("%d",a[i]);
  }
}


OUTPUT:

Enter the number
6
000000000000000000000000000110