Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <math.h>
  4.  
  5. // compile with:
  6. // gcc prog_long_long.c -o prog_long_long.exe
  7. // run with:
  8. // prog_long_long
  9.  
  10. unsigned long long int dec2bin(unsigned long long int);
  11.  
  12. int main(){
  13. unsigned long long int d,result;
  14.  
  15. printf("Enter an Integern");
  16.  
  17. scanf("%llu", &d);
  18.  
  19. result = dec2bin(d);
  20.  
  21. printf("The number in binary is %llun",result);
  22.  
  23. system("pause");
  24.  
  25. return 0;
  26. }
  27.  
  28. unsigned long long int dec2bin(unsigned long long int n){
  29. unsigned long long int rem;
  30. unsigned long long int bin=0;
  31. int i=1;
  32. while(n!=0){
  33. rem = n%2;
  34. n = n/2;
  35. bin = bin+(rem*i);
  36. i = i*10;
  37. }
  38. return bin;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement