namespace binary_to_decimal
{
class Program
{
static void Main(string[] args)
{
object r;
long i,n,sum = 0,k=0,u;
Console.WriteLine("enter the no of degit of the no");
n = Int64.Parse(Console.ReadLine());
u = Int64.Parse(Console.ReadLine());
r = u;
Console.WriteLine("the no" + r);
long[] b = new long[n];
Console.WriteLine("enter the no");
for (i = 0; i < n; i++)
{
b[i] = Int64.Parse(Console.ReadLine());
}
for (i = n-1; i >=0; i--)
{
sum = sum + b[i] * (int)Math.Pow(2, k);
k++;
}
Console.WriteLine("the no is " + sum);
}
}
}
{
class Program
{
static void Main(string[] args)
{
object r;
long i,n,sum = 0,k=0,u;
Console.WriteLine("enter the no of degit of the no");
n = Int64.Parse(Console.ReadLine());
u = Int64.Parse(Console.ReadLine());
r = u;
Console.WriteLine("the no" + r);
long[] b = new long[n];
Console.WriteLine("enter the no");
for (i = 0; i < n; i++)
{
b[i] = Int64.Parse(Console.ReadLine());
}
for (i = n-1; i >=0; i--)
{
sum = sum + b[i] * (int)Math.Pow(2, k);
k++;
}
Console.WriteLine("the no is " + sum);
}
}
}
No comments:
Post a Comment