Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Exercise 53

C Exercise 53

100 Classic C Language Examples 100 Classic C Language Examples

**Problem:** Learn to use the bitwise XOR ^.

**Program Analysis:** 0^0=0; 0^1=1; 1^0=1; 1^1=0.

Program source code:



//  Created by www.runoob.com on 15/11/9.

//  Copyright © 2015 Runoob Tutorial. All rights reserved.

//



#include 

int main()

{

    int a,b;

    a=077;

    b=a^3;

    printf("b 的值为 %d \n",b);

    b^=7;

    printf("b 的值为 %d \n",b);

    return 0;

}

The output of the above example is:



b 的值为 60 

b 的值为 59 

100 Classic C Language Examples 100 Classic C Language Examples