-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogic.c
More file actions
29 lines (27 loc) · 698 Bytes
/
logic.c
File metadata and controls
29 lines (27 loc) · 698 Bytes
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
#include <stdlib.h>
#include <stdio.h>
void logic_eg(int x, int y)
{
printf("x = 0x%.2x\n", 0xFF&(x));
printf("y = 0x%.2x\n", 0xFF&(y));
printf("x&y = 0x%.2x\n", 0xFF&(x&y));
printf("x&&y = 0x%.2x\n", 0xFF&(x&&y));
printf("x|y = 0x%.2x\n", 0xFF&(x|y));
printf("x||y = 0x%.2x\n", 0xFF&(x||y));
printf("~x|~y = 0x%.2x\n", 0xFF&(~x|~y));
printf("!x||!y = 0x%.2x\n", 0xFF&(!x||!y));
printf("x&!y = 0x%.2x\n", 0xFF&(x&!y));
printf("x&&~y = 0x%.2x\n", 0xFF&(x&&~y));
}
int main(int argc, char* argv[])
{
int x, y;
if (argc != 3) {
printf("Usage: %s x y\n", argv[0]);
exit(0);
}
sscanf(argv[1], "%x", &x);
sscanf(argv[2], "%x", &y);
logic_eg(x, y);
return 0;
}