Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Write a program to converting decimal to binary no

user-image
Question added by geeta sethi , faculty , apar india college
Date Posted: 2015/04/21
shahul maraikayar
by shahul maraikayar , Teradata developer , Flex international pvt ltd

include <iostream> using namespace std; int main() { long dec,rem,i=1,sum=0; cout<<"Enter the decimal to be converted:"; cin>>dec; do { rem=dec%2; sum=sum + (i*rem); dec=dec/2; i=i*; }while(dec>0); cout<<"The binary of the given number is:"<<sum<<endl; cin.get(); cin.get(); return 0; }

 

More Questions Like This