Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- long
- num,
- decimal_val = 0,
- base = 1,
- rem;
- scanf("%ld", &num);
- while (num > 0){
- rem = num % 10;
- decimal_val = decimal_val + rem * base;
- num = num / 10 ;
- base = base * 2;
- }
- printf("%ld", decimal_val);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement