Bitwise operations in C include bitwise operations (&), or (|), or (^), not (~). The following code package expands these basic operations, and there is also a two-digit Exchange (not a third number ). [Cpp] # include <stdio. h> # include <stdlib. h> // print a int in binary void bit_print (int a) {int I; int n = 16; int mask = 1 <(n-1); for (I = 1; I <= n; ++ I) {putchar (a & mask) = 0 )? '0': '1'); a <= 1; if (I % 8 = 0 & I <n) putchar ('');} printf ("\ n");} void inplace_swap (int * x, int * y) {* y = * x ^ * y; * x = * x ^ * y; * y = * x ^ * y;} int main () {int a = 19, B = 38; printf ("a:"); bit_print (); printf ("B:"); bit_print (B); printf ("~ A: "); bit_print (~ A); printf ("a & B:"); bit_print (a & B); printf ("a | B:"); bit_print (a & B ); printf ("a ^ B:"); bit_print (a ^ B); printf ("a = % d, B = % d \ n", a, B ); inplace_swap (& a, & B); printf ("After swap: \ n"); printf ("a = % d, B = % d \ n",, b); return 1 ;}# include <stdio. h> # include <stdlib. h> // print a int in binaryvoid bit_print (int a) {int I; int n = 16; int mask = 1 <(n-1); for (I = 1; I <= n; ++ I) {putchar (a & mask) = 0 )? '0': '1'); a <= 1; if (I % 8 = 0 & I <n) putchar ('');} printf ("\ n");} void inplace_swap (int * x, int * y) {* y = * x ^ * y; * x = * x ^ * y; * y = * x ^ * y;} int main () {int a = 19, B = 38; printf ("a:"); bit_print (); printf ("B:"); bit_print (B); printf ("~ A: "); bit_print (~ A); printf ("a & B:"); bit_print (a & B); printf ("a | B:"); bit_print (a & B ); printf ("a ^ B:"); bit_print (a ^ B); printf ("a = % d, B = % d \ n", a, B ); inplace_swap (& a, & B); printf ("After swap: \ n"); printf ("a = % d, B = % d \ n",, b); return 1;} logical operations include | ,&&,!, Corresponds to the OR, and, not. There are only two types of logical operations: TRUE or FALSE. 0 corresponds to FALSE. All values other than 0 are TRUE. Logical operations include the features of short-circuit evaluation: if the result of the expression can be determined by the first parameter, the logical expression will not evaluate the second parameter. A simple example: [cpp] # include <stdio. h> int main () {int a = 32, B = 43; printf ("a: % d, B: % d \ n", a, B ); printf ("! A: % d, a | B: % d, a & B: % d \ n ",! A, a | B, a & B); printf ("a ++ | B --: % d \ n", a ++ | B --); printf ("a: % d, B: % d \ n", a, B); // printf ("Hello \ n"); return 1 ;} # include <stdio. h> int main () {int a = 32, B = 43; printf ("a: % d, B: % d \ n", a, B ); printf ("! A: % d, a | B: % d, a & B: % d \ n ",! A, a | B, a & B); printf ("a ++ | B --: % d \ n", a ++ | B --); printf ("a: % d, B: % d \ n", a, B); // printf ("Hello \ n"); return 1 ;}