Showing posts with label decimal to binary. Show all posts
Showing posts with label decimal to binary. Show all posts

Decimal to Binary

SOURCE CODE:

#include iostream
#include conio (.) h

using namespace std;


int bintodec(int decimal)
{
int total = 0;
int power = 1;

while(decimal > 0)
{
total += decimal % 10 * power;
decimal = decimal / 10;
power = power * 2;
}
return total;
}

main()
{
int num;

cout << "Enter decimal: "; cin >> num;
cout <<>

getch();
}