class Program
{
static void Main(string[] args)
{
int x =1;
Console.WriteLine("Hello World");
Console.Write("\nEnter Binary number : ");
string bin = Console.ReadLine();
Console.WriteLine("\nBinary number is " + BinToDec(bin));
Console.Write("Good Buy");
Console.Read();
}
static double BinToDec(string bin)
{
int i = (bin.Length - 1);
double sum = 0, j = 0;
while (i >= 0)
{
sum += Convert.ToDouble(bin.Substring(i, 1)) * Convert.ToDouble(Math.Pow(2.00, Convert.ToDouble(j)));
j++;
i--;
}
return sum;
}
}
}
for (int i = 0; i < 100; i++)
{
Console.WriteLine("Hello World");
Console.Write("\nEnter Binary number : ");
string bin = Console.ReadLine();
Console.WriteLine("\nBinary number is " + BinToDec(bin));
Console.Write("Good Buy");
Console.Read();
}