& (Bitwise And) Operator - C++ Operator

C++ examples for Operator:Bit Operator

Introduction

& Operator returns a value that has all of the bits that were set in both the left and right sides of the operator.

Demo Code

#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int bits{ 0x00011000 };
    cout << showbase << hex;
    cout << "Result of 0x00011000 & 0x00011000: "  << (bits & bits) << endl;
    cout << "Result of 0x00011000 & 0x11100111: "  << (bits & ~bits) << endl;

    return 0;/*from w  w w .  ja  va 2s.  c  o  m*/
}

Result


Related Tutorials