program to convert binary to decimal using c

#include<stdio.h>
int main()
{
    int n,rem,d,j=1,dec=0;
    printf("Enter the number in binary");
    scanf("%d",&n);
   while(n>0)
   {
       rem=n%10;
       d=rem*j;
       dec=dec+d;
      j*=2;
      n=n/10;
   }
   printf("decimal is=%d",dec);
}

Comments

Popular posts from this blog

BYTE STUFFING PROGRAM USING C

Rotate a matrix 270 degree AntiClockWise

Finding the length of connected cells of 1's (regions) in an matrix of 1's and 0's