a) // toggles bit 11 in x
x ^= 1 <<11;
//*********************************
b) // clearall bits except bit 3 (fourth bit) in x
x&=(1<<3);
std::cout << (int) x << std::endl;
//*************************************
c) //set bits 0,1,2,3
for (int i = 0; i !=4; i++)
x |= (1<<i);
std::cout << (int)x << std::endl;
std::cout << '\n';
#include <iostream>
#include <iomanip>
int main()
{
unsigned x {};
// toggles bit 11 (twelfth bit) in x
x ^= 1 << 11;
std::cout << std::hex << x << '\n';
//*********************************
// clear all bits except bit 3 (fourth bit) in x
x = 0xff;
x &= (1 << 3);
std::cout << std::hex << x << '\n';
//*************************************
//set bits 0,1,2,3
x |= 0xf;
std::cout << std::hex << x << '\n';
}
thanks again,
I noticed that you guys talking about error in the code above, could you please rewrite the code above in a new correct way and thanks for your effort helping me
the important here is not to write a program but to solve the a b c as syntax
My favorite is my Apple Magic Keyboard. I have used several other types, including Apple's latest version on their newest MacBook Pro (13"), and this one is still my favorite.
It has lasted me 12 years without a glitch or a grumble, and the keys aren't wearing off! Unlike my PC keyboard at work, which I replaced 4 times over about 5 years due to letters wearing off or "going bad," a term which covers a number of electronic issues. Finally I got a Magic Keyboard to hook up to the PC and that solved it.