Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- Console.Write("Number: ");
- int i = int.Parse(Console.ReadLine());
- Console.Write("Position of the bit: ");
- int b = int.Parse(Console.ReadLine());
- int mask = 1 << b;
- Console.WriteLine("The {0} bit in {1} is {2}", b, i, (i&mask) != 0 ? 1 : 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment