Today we Make Program of C++ Program to Convert Decimal to Binary.it is Very easy and Simple.Now Try To make it.
C++ Program to Convert Binary Number to Decimal
#include<iostream> #include<conio.h> 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 binary number: 1111 1111 in binary = 15
Enter the number to convert: 9 Binary of the given number= 1001