Easy Tutorial
❮ C Function Isalnum C Standard Library Errno H ❯

C Exercise Example 51

C Language Classic 100 Examples

Title: Learning to use bitwise AND &.

Program Analysis: 0&0=0; 0&1=0; 1&0=0; 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("a & b (decimal) is %d \n", b);
    b &= 7;
    printf("a & b (decimal) is %d \n", b);
    return 0;
}

Output of the above example:

a & b (decimal) is 3 
a & b (decimal) is 3

C Language Classic 100 Examples

❮ C Function Isalnum C Standard Library Errno H ❯