If you have studied number system then you must have heard about the different
  types of numbers like decimal, binary , Octal, hexadecimal these are just number
  system in which codes are written in computer like computer understand binary
  and color we use in computer has their own hexadecimal values.
  So, through this program we will be doing conversation between Binary number
  to Decimal number.  

 Program

  #include<stdio.h>

  #include<math.h>

   void main()

   {

    int n,pow=1,rem,sum=0;

    printf("Enter the binary number :");

    scanf("%d",&n);

    for(n=n ; n>0 ; )

       {

         rem=n%10;

         sum=sum+rem*pow;

         pow=pow*2;

         n=n/10;

        }

      printf("%d is the decimal conversion",sum);

    }

  Output:
 

 Here, Binary number entered is 11010 and output is 26 which is the decimal conversion of the binary number.


Post a Comment

Previous Post Next Post