class Program
{
static void Main(string[] args)
{
int num, temp = 1, n = 0;
Console.Write("Enter a Number : ");
num = int.Parse(Console.ReadLine());
while (num > 0)
{
if (num % 2 == 1)
n = n + temp;
num = num / 2;
temp = temp * 10;
}
Console.WriteLine("The Binary format for given number is: {0}", n);
Console.ReadLine();
}
}
No comments:
Post a Comment