डाउनलोड पी.डी.एफ. ई-बुक्स
C - Binary To Decimal Conversion

विवरण :

Click to Convert Binary To Decimal Number

सोर्स कोड :

#include<stdio.h>
#include

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;
}

आउटपुट :

Enter binary value(0 and 1): 100 
Decimal number= 4