Binary To Decimal Conversion

in Hindi - Binary To Decimal Conversion



Click to Convert Binary To Decimal Number

Source Code :

RUN#include <stdio.h>
#include<math.h>

int main()
{
int num, rem=0, num1=0, i=0;
printf("Enter binary value(0 and 1): ");
scanf("%d",&num);

while(num > 0){
rem = num % 10;
num1 = num1 + rem * pow(2, i);
i++;
num = num / 10 ;
}
printf("Decimal number= %d ", num1);

return 0;
}