Illustrate Bitwise Operators - C Operator

C examples for Operator:Bit Operator

Description

Illustrate Bitwise Operators

Demo Code

#include <stdio.h>

int main (void){
    int w1 = 125u, w2 = 707u, w3 = 12u;

    printf ("%o    %o   %o\n", w1 & w2, w1 | w2, w1 ^ w2);
    printf ("%o    %o   %o\n", ~w1, ~w2, ~w3);
    printf ("%o    %o   %o\n", w1 ^ w2, w1 & ~w2, w1 | w2 | w3);
    printf ("%o    %o\n", w1 | w2 & w3, w1 | w2 & ~w3);
    printf ("%o    %o \n", ~(~w1 & ~w2), ~(~w1 | ~w2));

    w1 ^= w2;/*from   w  w  w  .  java  2s. co  m*/
    w2 ^= w1;
    w1 ^= w2;
    printf ("w1 = %o, w2 = %o\n", w1, w2);

    return 0;
}

Result


Related Tutorials