/*
binary.cpp
Written by: Ken M. (CheckMate)
Written to: Change decimal numbers into binary numbers.
*/

#include 

// main function
int main()
{
  // necessary variables
  int num,left;
  int iarray[21],count;

  float x;

  cout << "Welcome to CheckMate's decimal to binary converter (CONVERT).\n";
  cout << "Just type in a decimal number, and you will get the binary equality.\n";
  cout << "To exit enter the number 0.\n\n";

  do
  {
    // initiate all numbers in the array to 0
    for (count = 0; count < 21; count++)
      iarray[count] = 0;

    // get input from user
    cout << "Enter number: ";
    cin >> num;

    // check if user wants to leave
    if (num == 0)
      break;

    // set count back to 0
    count = 0;

    // binary loop
    while(1)
      {
	// make x = num divided by 2
	x = num/2;

	// see if there is a remainder, 0 = no, 1 = yes
	left = num % 2;

	// round x down
	num = x;

	// add to the array
	iarray[count] = left;
      
	// move to next position in the array
	count++;

	// check if we are done yet
	if (num == 0) 
	  break;
      }

    // display the binary number
    for (count = count -1; count > 0; count--)
      {
	cout << iarray[count];
      }

    // display the end line character
    cout << endl;

  } while(1);  

  cout << "Thank you for using BCONVERT 1.0\n";

  // exit
  return 0;
}

    Source: geocities.com/hiddenbunkerlabs/code

               ( geocities.com/hiddenbunkerlabs)