Syntax fix and file rename Binary_To_Decimal.c, remove executable

This commit is contained in:
KylerSmith 2017-07-12 16:59:31 -07:00
parent fd8d20e907
commit df24845286
3 changed files with 25 additions and 17 deletions

View File

@ -1,17 +0,0 @@
#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);
}

25
Binary_To_Decimal.c Normal file
View File

@ -0,0 +1,25 @@
/**
* Modified 07/12/2017, Kyler Smith
*
*/
#include <stdio.h>
int main() {
int remainder, number = 0, decimal_number = 0, temp = 1;
printf("Enter any binary number= ");
scanf("%d", &number);
// Iterate over the number until the end.
while(number > 0) {
remainder = number % 10;
number = number / 10;
decimal_number += remainder * temp;
temp = temp*2; //used as power of 2
}
printf("%d\n", decimal_number);
}

BIN
a.out

Binary file not shown.