fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int arr[200]; //for storing the binary representation of num
  5. int i=0; // to keep the count of the no of digits in the binary representation
  6.  
  7. void calBinary(int n) // function to recalculate
  8. {
  9. if(n>1)
  10. calBinary(n/2);
  11. arr[i++]=n%2;
  12. }
  13.  
  14. int main() {
  15. int num=4;
  16. calBinary(num);
  17. for(int j=0;j<i;j++)
  18. cout << arr[j];
  19. return 0;
  20. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
100