Friday, June 17, 2016

C Program to demonstrate use of bitwise OR operator.


/*
Example of bitwise OR operation on two numbers 30 and 25.

30 in binary is 00011110
25 in binary is 00011001

Bitwise OR operation on 30 and 25 is as under:

   00011110 
OR 00011001
=========
   00011111 i.e. 31
*/

#include <stdio.h>
int main()
{
    int num1 = 30, num2 = 25;
    printf("Bitwise OR operation: num1 OR num2 is %d", num1|num2);
    return 0;
}

Output of program

Bitwise OR operation: num1 OR num2 is 31

No comments:

Post a Comment