C program to demonstrate bitwise operator

//C program to demonstrate bitwise operator:-


#include <stdio.h>
#include<conio.h>
void  main()
{
   int m,n,AND_opr,OR_opr,XOR_opr,NOT_opr ;
   clrscr();
   printf("Enter any two interger numbers:",m,n);
   scanf("%d%d",&m,&n);
   printf("m=%d and n=%d:\n ",m,n);
   AND_opr = (m&n);
   OR_opr = (m|n);
   NOT_opr = (~m);
   XOR_opr = (m^n);
   printf("AND_opr value = %d\n",AND_opr);
   printf("OR_opr value = %d\n",OR_opr);
   printf("NOT_opr value = %d\n",NOT_opr);
   printf("XOR_opr value = %d\n",XOR_opr);
   printf("left_shift value = %d\n",m<<1);
   printf("right_shift value = %d\n",m>>1);
   getch();
}

============================
OUTPUT:-

Enter any two interger numbers:20 60
m=20 and n=60:                                                                 
 AND_opr value = 20                                                            
OR_opr value = 60                                                              
NOT_opr value = -21                                                            
XOR_opr value = 40                                                             
left_shift value = 40                                                          
right_shift value = 10
============================

C program to demonstrate bitwise operator

Comments