Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class ThirdBitCheck
- {
- static void Main(string[] args)
- {
- int intNumber = 0;
- Console.WriteLine("Please enter an integer number:");
- intNumber = int.Parse(Console.ReadLine());
- int mask = 1 << 3;
- int checkMask = intNumber & mask;
- if (checkMask == 0)
- {
- Console.WriteLine(@"The Third Bit of your number '{0}' is 0", intNumber);
- }
- else
- {
- Console.WriteLine(@"The Third Bit of your number '{0}' is 1", intNumber);
- }
- // for bool type expression if and else should be replaced by true/false
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement