본문 바로가기
C

비트연산자

by sj0020 2020. 7. 15.

 

#include <stdio.h>
int main() {
	unsigned char input;  // 0000 0011
	unsigned char b = 6;  // 0000 0110
	
	scanf("%hhu", &input);
	
	unsigned char c = input & b;
	unsigned char d = input | b;
	unsigned char e = input ^ b;
	unsigned char f = ~ input;

	c = input & b;
	d = input | b;
	e = input ^ b;
	f = ~ input;
	
	printf("%d %d %d %d", c, d , e, f);
	
	return 0;
}