montimaj

SET NTH BIT

Mar 29th, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.19 KB | None | 0 0
  1. //Setting the nth bit of an integer
  2. #include<iostream>
  3. int main()
  4. {
  5.     int n,m;
  6.     std::cout<<"Enter n and m: ";
  7.     std::cin>>n>>m;
  8.     int k=n|1<<m;
  9.     std::cout<<"Output= "<<k;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment