Advertisement
remote87

First Bit

Aug 27th, 2015
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _07.FirstBit
  8. {
  9.     class FirstBit
  10.     {
  11.         static void Main()
  12.         {
  13.             Console.Write("Enter a number: ");
  14.             int number = int.Parse(Console.ReadLine());
  15.             Console.Write("Enter a position to check bit: ");
  16.             int position = int.Parse(Console.ReadLine());
  17.             int result = number >> position;
  18.             Console.WriteLine(result & 1);
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement