Wednesday, September 28, 2016

Decimal To Binary Conersion

Program to Convert Decimal Number To Binary Equivalent:


#include<iostream>
using namespace std;
main()
{
int num,binary[50],i=0;
cout<<"\nEnter Any Decimal Number ";
cin>>num;
while(num>0)
{
binary[i]=num%2;   //finding remainder
num=num/2;
i++;
}
cout<<"\nBinary Equivalent is ";
for(int j=i-1;j>=0;j--)  //from down to top moving
cout<<binary[j];
}
Also see program to evaluate postfix expression Click Here

Output: