Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(void){
- int decimal,binary,position;
- //binary = 11000;
- position = 1;
- decimal = 0;
- printf("Enter binary number: ");
- scanf("%d",&binary);
- while (binary > 0){
- decimal += (binary % 10) * position;
- binary /= 10;
- position *= 2;
- }
- printf("Decimal Equivalent: %d",decimal);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement