CONVERT GIVEN DECIMAL NUMBER INTO BINARY NUMBER


#include<stdio.h>
#include<conio.h>
main()
{
    int k=0,n,i,rem,x[10];
    clrscr();
     printf("PLEASE ENTER THE DESIMAL NO:");
    scanf("%d",&n);
    while(n!=1)
  {
    rem=n%2;
    x[k]=rem;
    n=n/2;
    k++;
  }
    x[k]=1;
    printf("\nTHE BINARY EQUIVALENT IS:");
             for(i=k;i>=0;i--)
    printf("%d",x[i]);
  getch();
}

0 comments: (+add yours?)

Post a Comment