Decimal number is a base 10 number because it ranges from 0 to 9, there are total of 10 digits between 0 to 9.decimal number such as 223, 585, 192, 0, 7, etc.You will get the program to convert a number from decimal to binary in C++.
Binary number is a base 2 number because it is either 0 or 1.binary number such as 1001, 101, 11111, 101010, etc.
C++ Program to Convert Decimal to Binary
#include<iostream>
using namespace std;
int main()
{
int d,n,i,j,a[50];
cout<<"Enter a Number:";
cin>>n;
cout<<"\nThe binary conversion of "<<n<<" is 1";
for(i=1;n!=1;++i)
{
d=n%2;
a[i]=d;
n=n/2;
}
for(j=i-1;j>0;--j)
cout<<a[j];
return 0;
}
Output of Program
Enter a Number:35
The binary conversion of 35 is 100011