22: Write a program to demonstrate bitwise
operator.
Please follow me for more practicals....
Program:
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
int num1, num2;
printf("Enter the 1st number = ");
scanf("%d", &num1);
printf("Enter the 2nd number = ");
scanf("%d", &num2);
printf("\n%d & %d = %d", num1,
num2, num1 & num2);
printf("\n%d | %d = %d", num1, num2,
num1 | num2);
printf("\n%d ^ %d = %d", num1, num2,
num1 ^ num2);
printf("\n~%d = %d", num1, ~num1);
printf("\n~%d = %d", num2, ~num2);
printf("\n%d << %d = %d", num1,
num2, num1 << num2);
printf("\n%d >> %d = %d", num1,
num2, num1 >> num2);
getch();
}
Please follow me for more practicals....
Output:
Enter the 1st number = 5
Enter the 2nd number = 4
5 & 4 = 4
5 | 4 = 5
5 ^ 4 = 1
~5 = -6
~4 = -5
5 << 4 = 80
5 >> 4 = 0
Please follow me for more practicals....
Algorithm:
1. START
2. Declare num1, num2.
3. Enter the num1 and num2
4. Display value of (num1 & num2), (num1 | num2), (num1
^ num2), (~num1), (~num2), (num1 << num2) and (num1 >> num2).
5. STOP
Please follow me for more practicals....
Flowchart: