Easy Tutorial
❮ C Exercise Example19 C Decision ❯

C Exercise Example 52

C Language Classic 100 Examples

Title: Learning to use the bitwise OR |.

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

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("b 的值为 %d \n",b);
    b|=7;
    printf("b 的值为 %d \n",b);
    return 0;
}

The output of the above example is:

b 的值为 63 
b 的值为 63

C Language Classic 100 Examples

❮ C Exercise Example19 C Decision ❯