stkirov

Untitled

Oct 7th, 2012
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.37 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         Console.Write("Number: ");
  8.         int i = int.Parse(Console.ReadLine());
  9.         Console.Write("Position of the bit: ");
  10.         int b = int.Parse(Console.ReadLine());
  11.  
  12.         int mask = 1 << b;
  13.  
  14.         Console.WriteLine("The {0} bit in {1} is {2}", b, i, (i&mask) != 0 ? 1 : 0);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment