Binary To Decimal

This commit is contained in:
Anup Kumar Panwar 2016-07-27 15:52:38 +05:30
parent 875f88a093
commit e65a50c983

17
binarytodecimal.c Normal file
View File

@ -0,0 +1,17 @@
#include<stdio.h>
#include<conio.h>
int main(){
int number,decimal_number,temp=1;
printf("Enter any binary number= ");
scanf("%d",&number);
int remainder;
while(number>0){
remainder= number%10;
number=number/10;
decimal_number+=remainder*temp;
temp=temp*2;//used as power of 2
}
printf("%d",decimal_number);
}