Welcome to Bitwise operators.
Do the following operations using Bitwise operators:
Input-output format:
Input consists of unsigned integers
Refer sample Input Output for output format.
Sample Input and Output:
AND
Enter a and b
7
4
aANDb = 4
OR
Enter a and b
3
4
aORb = 7
XOR
Enter a and b
4
2
aXORb = 6
Program Code:
#include<stdio.h>
int main()
{
int a, b;
printf("AND\n");
printf("Enter a and b\n");
scanf("%d", &a);
scanf("%d", &b);
printf("aANDb = %d\n\n", a&b);
printf("OR\n");
printf("Enter a and b\n");
scanf("%d", &a);
scanf("%d", &b);
printf("aORb = %d\n\n", a|b);
printf("XOR\n");
printf("Enter a and b\n");
scanf("%d", &a);
scanf("%d", &b);
printf("aXORb = %d\n\n", a^b);
return 0;
}
Post A Comment:
0 comments: