From fa53b2fcce3a927044f9a76aa36efe60b3feaba0 Mon Sep 17 00:00:00 2001 From: Saumay-Agrawal Date: Mon, 6 Feb 2017 23:29:22 +0530 Subject: [PATCH] Update Binary to Decimal.c Improved the readability of the program. --- Binary To Decimal.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Binary To Decimal.c b/Binary To Decimal.c index cc7caff8..93cb7d3f 100644 --- a/Binary To Decimal.c +++ b/Binary To Decimal.c @@ -1,17 +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); +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); }