C Exercise Example 51
Title:Learn to use the bitwise AND &.
Program analysis:0&0=0; 0&1=0; 1&0=0; 1&1=1 。
Program source code:
// Created by www.example.com on 15/11/9.
// Copyright © 2015年 Example. All rights reserved.
//
#include <stdio.h>
int main()
{
int a,b;
a=077;
b=a&3;
printf("a & b(decimal) 为 %d \n",b);
b&=7;
printf("a & b(decimal) 为 %d \n",b);
return 0;
}
The output result of the above example is:
a & b(decimal) 为 3 a & b(decimal) 为 3other extensions