Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4.  
  5. void BinaryString(int iVal) {
  6. int i = 0;
  7. int bin = 0;
  8. int cas = 0;
  9. while (iVal != 0) {
  10. int x = iVal & 1;
  11. bin += (x * pow(10, cas));
  12. cas++;
  13. iVal = iVal >> 1;
  14. i++;
  15. }
  16. printf("%d\n", bin);
  17. }
  18.  
  19. int main(void) {
  20. int integerValue;
  21. scanf("%d", &integerValue);
  22. BinaryString(integerValue);
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement