using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _2_lik_sistem
{
class Program
{
static void Main(string[] args)
{
double us, c, toplam = 0;
int boy, sayi;
string s;
char a;
Console.Write("2'lik sistemde bir sayı giriniz=");
s = Console.ReadLine();
boy = s.Length;
Console.Write("Girilen sayının uzunluğu={0}", boy);
for (int i = 0; i < boy; i++)
{
a = s;
sayi = Convert.ToInt16(a);
sayi = sayi - 48;
us = Math.Pow(2, boy - (i + 1));
c = sayi * us;
toplam = toplam + c;
Console.WriteLine(sayi + "x" + us + "=" + c);
}
Console.Write("Sayiların 10'luk tabanda karşılığı={0}", toplam + "n");
Console.ReadLine();
}
}
}
kaynak
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _2_lik_sistem
{
class Program
{
static void Main(string[] args)
{
double us, c, toplam = 0;
int boy, sayi;
string s;
char a;
Console.Write("2'lik sistemde bir sayı giriniz=");
s = Console.ReadLine();
boy = s.Length;
Console.Write("Girilen sayının uzunluğu={0}", boy);
for (int i = 0; i < boy; i++)
{
a = s;
sayi = Convert.ToInt16(a);
sayi = sayi - 48;
us = Math.Pow(2, boy - (i + 1));
c = sayi * us;
toplam = toplam + c;
Console.WriteLine(sayi + "x" + us + "=" + c);
}
Console.Write("Sayiların 10'luk tabanda karşılığı={0}", toplam + "n");
Console.ReadLine();
}
}
}
kaynak