Make a new start with a new Thought!

NOTE :                // indicates comments.This wont get printed in the output.This is used for for documentation purpose. PROGRAM: #incl...

Binary To HeXaDecimal Conversion

NOTE :
              
// indicates comments.This wont get printed in the output.This is used for for documentation purpose.

PROGRAM:

#include<stdio.h>
#include<conio.h>
void main()
{
  long int binary,hex=0,i=1,rem;
  clrscr();
  printf("\nEnter any binary number\t:\t");
  scanf("%ld",&binary);
  while(binary!=0)
  { 
     rem=binary%10;
     hex=hex+rem*i;
     i=i*2;
     binary=binary/10;
  }
  printf("\nThe Equivalent HexaDecimal is \t:\t%\X",hex);
  getch();
}

OUTPUT :

0 comments: