Decimal number:
range : 0 to 9
Binary number :
range : 0 to 1
Decimal to binary conversion:
Example-
Decimal number is 8
Binary number is 1000
Decimal number is 23
Binary number is 10111
program:
#include< iostream>
int main() {
int n,num=0;
cout<<"Enter decimal number"<< endl;
cin>>n;
while(n)
{
num=num*10+n%2;
n=n/2;
}
cout<<"It's binary is "<< num;
}
Enter decimal number
7
It's binary is 111
Enter decimal number
10
It's binary is 1010