From e65a50c98330a8cc46eb56d4a557faaacf9b0597 Mon Sep 17 00:00:00 2001 From: Anup Kumar Panwar Date: Wed, 27 Jul 2016 15:52:38 +0530 Subject: [PATCH] Binary To Decimal --- binarytodecimal.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 binarytodecimal.c diff --git a/binarytodecimal.c b/binarytodecimal.c new file mode 100644 index 00000000..cc7caff8 --- /dev/null +++ b/binarytodecimal.c @@ -0,0 +1,17 @@ +#include +#include +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); +}