Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int num, bVal, dVal = 0, base = 1, rem;
  6.  
  7.  
  8. printf("Enter fibinary number: ");
  9. scanf("%d", &num);
  10.  
  11. bVal = num;
  12.  
  13. while (num > 0)
  14. {
  15. rem = num % 10;
  16. dVal = dVal + rem * base;
  17. num = num / 10 ;
  18. base = base * 2;
  19. }
  20.  
  21. printf("Output: %d \n", dVal);
  22.  
  23.  
  24.  
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement