-
Notifications
You must be signed in to change notification settings - Fork 359
/
BitwiseOpration.c
50 lines (49 loc) · 1.06 KB
/
BitwiseOpration.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <stdio.h>
#include <math.h>
int main()
{
int num_1, num_2, result;
char op;
printf("Enter A to perform Bitwise AND \n");
printf("Enter B to perform Bitwise OR \n");
printf("Enter C to perform Bitwise XOR \n");
printf("Enter D to perform Bitwise NOT \n");
scanf("%c",&op);
switch (op)
{
case 'A':
printf("Enter the first number : ");
scanf("%d",&num_1);
printf("Enter the second number : ");
scanf("%d",&num_2);
result = num_1 & num_2;
printf("%d",result);
break;
case 'B':
printf("Enter the first number : ");
scanf("%d",&num_1);
printf("Enter the second number : ");
scanf("%d",&num_2);
result = num_1 | num_2;
printf("%d",result);
break;
case 'C':
printf("Enter the first number : ");
scanf("%d",&num_1);
printf("Enter the second number : ");
scanf("%d",&num_2);
result = num_1 ^ num_2;
printf("%d",result);
break;
case 'D':
printf("Enter the number : ");
scanf("%d",&num_1);
result = !num_1;
printf("%d",result);
break;
default:
printf("Invalid Choice \n");
break;
}
return 0;
}