Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //Write a program to convert binary numbers to their decimal representation
- class Program
- {
- static void Main()
- {
- Console.WriteLine("Enter binary number : ");
- string convert = Console.ReadLine();
- int result = 0;
- for (int i = convert.Length - 1, j = 0; i >= 0; i--, j++)
- {
- if (convert[i] == '1')
- {
- result ^= 1 << j;
- }
- }
- Console.WriteLine("Converted number :");
- Console.WriteLine(result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement