Advertisement
Rakibul_Ahasan

Problem-01->DecimalToBinary (Lab-01/Numerical)

Feb 10th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     vector<long long int>v;
  7.     long long int n;
  8.     cin>>n;
  9.     while(n!=0){
  10.     long long int r=n%2;
  11.         n=n/2;
  12.         v.push_back(r);
  13.     }
  14.  
  15.     reverse(v.begin(),v.end());
  16.  
  17.     for(int i=0;i<v.size();i++)
  18.         cout<<v[i]<<" ";
  19.     cout<<"\n";
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement