Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BitPosition
- {
- static void Main() {
- Console.Write("Input a number n:");
- int number = int.Parse(Console.ReadLine());
- Console.WriteLine("Input position p(0 the right bit):");
- int p = int.Parse(Console.ReadLine());
- int bit = (number >> p) & 1;
- Console.WriteLine($"On posion {p} we have: {bit}");
- }
- }
Advertisement