Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main()
- {
- int p = 3;
- Console.WriteLine("Enter a random number to extract the third bit from its binary conversion.");
- int n = int.Parse(Console.ReadLine());
- int nRightP = n >> p;
- int bit = nRightP & 1;
- Console.WriteLine("The third bit of the number {0} is {1}.", n, bit);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement