mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 05:21:49 +03:00
Syntax fix and file rename Binary_To_Decimal.c, remove executable
This commit is contained in:
parent
fd8d20e907
commit
df24845286
@ -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
25
Binary_To_Decimal.c
Normal 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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user