Skip to content

Commit

Permalink
Merge pull request TheAlgorithms#19 from theycallmemac/patch-8
Browse files Browse the repository at this point in the history
Rename Binary To Decimal.c to Conversions/Binary To Decimal.c
  • Loading branch information
r0hit-gupta authored Aug 8, 2017
2 parents c56098d + bc37db6 commit 247267b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Conversions/Binary To Decimal.c
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 247267b

Please sign in to comment.