Here is an example of bitwise calculation using bitwise AND, OR, XOR, 1's Complement
Code goes like this :
/* Program using bitwise AND, OR, XOR and 1's Complement operator */
#include<stdio.h>
int main()
{
int a, b;
printf("Enter two numbers : ");
scanf("%d %d",&a, &b);
printf("\n Bitwise AND calculation %d\n",a&b); // bitwise AND &
printf("\n Bitwise OR calculation %d\n",a|b); // bitwise OR |
printf("\n Bitwsie XOR calculation %d\n",a^b); //bitwise XOR ^
printf("\n Bitwsie 1\'s Complement calculation %d\n",b=~a); //bitwise 1's complement
return 0;
}
Output :
I have used Dev CPP to compile this program.
If you are using Turbo C++
IDE, then use conio.h in link section after stdio.h
and use getch(); to
hold the output screen, just before the end of main function.
If you have any confusion regarding the program, please, comment below.
Happy Coding !
Thank you.
Bitwise Calculation In C Programming
3:48 PM
Bitwise 1's Complement
,
Bitwise AND
,
Bitwise Operator in C Language
,
Bitwise OR
,
Bitwise XOR
,
C Programming Bitwise Calculation examples
Edit
0 comments:
Post a Comment