Decimal To Binary

This algorithm converts decimal numbers to binary numbers.



									/*****Please include following header files*****/
// string
/***********************************************/

/*****Please use following namespaces*****/
// std
/*****************************************/

static string DecimalToBinary(int dec) {
	if (dec < 1) return "0";

	string binStr = "";

	while (dec > 0)
	{
		binStr = binStr.insert(0, to_string(dec % 2));
		dec /= 2;
	}

	return binStr;
}
								


Example

									int data = 6207166;
string value = DecimalToBinary(data);
								


Output

									10111101011011010111110