// Sibel Salimova <[email protected]>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DecimalToBinary
{
class Program
{
static void Main(string[] args)
{
int dec;
Console.WriteLine("Enter a decimal number!");
dec=int.Parse(Console.ReadLine());
int a;
string b = "";
while (dec >= 1) {
a = dec / 2;
b += (dec % 2).ToString();
dec = a;
}
string bin = "";
for (int i = b.Length - 1; i >= 0; i--) {
bin = bin + b[i];
}
Console.WriteLine("Binary: {0}", bin);
Console.Read();
}
}
}
Comments