Advertisement
stanevplamen

01.3.5.ThirdBitCheck

Apr 28th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2.  
  3. class ThirdBitCheck
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int intNumber = 0;
  8.         Console.WriteLine("Please enter an integer number:");
  9.         intNumber = int.Parse(Console.ReadLine());
  10.         int mask = 1 << 3;
  11.         int checkMask = intNumber & mask;
  12.  
  13.         if (checkMask == 0)
  14.         {
  15.             Console.WriteLine(@"The Third Bit of your number '{0}' is 0", intNumber);
  16.         }
  17.         else
  18.         {
  19.             Console.WriteLine(@"The Third Bit of your number '{0}' is 1", intNumber);
  20.         }
  21.         // for bool type expression if and else should be replaced by true/false
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement