class Program
{
static void Main(string[] args)
{
int n, binary, decml = 0, a = 1, reminder;
Console.WriteLine("Enter the Binary number which is 0 and 1 format");
n = int.Parse(Console.ReadLine());
binary = n;
while (n > 0)
{
reminder = n % 10;
decml = decml + reminder * a;
n = n / 10;
a = a * 2;
}
Console.WriteLine("The Binary number is " + binary);
Console.WriteLine("The Deciaml number is :" + decml);
Console.WriteLine();
Console.ReadLine();
}
}
}
No comments:
Post a Comment