Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Tri_Bit_Switch
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter your number here: ");
- int number = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter the position of the first out of 3 bits you want to invert: ");
- int firstPos = int.Parse(Console.ReadLine());
- int helpNum = 7 << firstPos;
- int invertedNumber = number^helpNum;
- Console.WriteLine(invertedNumber);
- }
- }
- }
Add Comment
Please, Sign In to add comment