Easy Tutorial
❮ C Examples Multiplication Table C Exercise Example18 ❯

C Exercise Example 53

C Language Classic 100 Examples

Title: Learn to use bitwise XOR ^.

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

Program Source Code:

//  Created by www.tutorialpro.org on 15/11/9.
//  Copyright © 2015 tutorialpro.org. All rights reserved.
//

#include <stdio.h>
int main()
{
    int a,b;
    a=077;
    b=a^3;
    printf("The value of b is %d \n",b);
    b^=7;
    printf("The value of b is %d \n",b);
    return 0;
}

The output of the above example is:

The value of b is 60 
The value of b is 59

C Language Classic 100 Examples

❮ C Examples Multiplication Table C Exercise Example18 ❯