-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d27bd3
commit 2604c9a
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...ning_C/T. Classic programs (eg palindrome)/Number Conversion/programs/binary_to_decimal.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// #include <stdio.h> | ||
// int main() | ||
// { | ||
// int num, num_in_binary, num_in_decimal = 0, base = 1, rem; | ||
// printf ("Enter a binary number with the combination of 0s and 1s \n"); | ||
// scanf ("%d", &num); | ||
|
||
// num_in_binary = num; | ||
|
||
|
||
// while ( num > 0) | ||
// { | ||
// rem = num % 10; /* divide the binary number by 10 and store the remainder in rem variable. */ | ||
// num_in_decimal = num_in_decimal + rem * base; | ||
// num = num / 10; // divide the number with quotient | ||
// base = base * 2; | ||
// } | ||
|
||
// printf ( " The binary number is %d \t", num_in_binary); // print the binary number | ||
// printf (" \n The decimal number is %d \t", num_in_decimal); // print the decimal | ||
// } |