Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ex3
- {
- class Program
- {
- static void Main(string[] args)
- {
- // set the bit at position p to 1
- int p = 2;
- int n = 42; //00101010
- int bit = (1 << p); //00000100
- int result = n | bit; //00101110
- Console.WriteLine(result); //46
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment