Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Loops
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter BIN: ");
- int num = int.Parse(Console.ReadLine());
- int num1 = num;
- int dec = 0;
- int power = 0;
- while (num != 0)
- {
- int digit = num % 10;
- dec += digit * (int)Math.Pow(2, power);
- power++;
- num /= 10;
- }
- Console.WriteLine($"{num1}(2) = {dec}(10)");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement