#include <iostream>
using namespace std;
void updateIthBit(int num, int i, int val) {
// clear ith bit
num = num & ~(1<<i);
//numbitmask
num = num | (val << i);
cout << num << endl;
}
int main()
{
updateIthBit(7, 3, 1);
return 0;
}
#include <iostream> using namespace std; struct Node { int data; Node* next; }; class Stack { Node* top; public: Stac...
No comments:
Post a Comment