amritansh22 / Data-Structures-and-Algorithms-in-cpp

This repository is in development phase and will soon provide you with c++ code of various data structures and algorithms
MIT License
366 stars 341 forks source link

Decimal to Binary Conversion #555

Open nikhilsharma2020 opened 2 years ago

nikhilsharma2020 commented 2 years ago

include

using namespace std;
int main()
{
int a[10], n, i;
cout<<"Enter the number to convert: ";
cin>>n;
for(i=0; n>0; i++)
{
a[i]=n%2;
n= n/2;
}
cout<<"Binary of the given number= ";
for(i=i-1 ;i>=0 ;i--)
{
cout<<a[i];
}
}