Monday, September 12, 2011

convert decimal number into binary

// to convert decimal  number into binary
#include<stdio.h>
#include<conio.h>
main()
{
    int n,a[25],i=0,j;
    clrscr();
    printf("\n Enter any integer : ");
    scanf("%d",&n);
    while(n>0)
    {
        a[i]=n%2;
        n=n/2;
        i++;
    }
    for(j=i-1;j>=0;j--)
      printf(" %d ",a[j]);
       getch();
}

No comments:

Post a Comment

Popular 5 Posts Last 7 days