목록CPP (65)

논리 연산자 (Logical operators) 관계 연산자(relational operator)는 특정 조건이 true 인지 false 인지를 테스트 할 수 있지만 한번에 하나의 조건만 테스트 할 수 있다. 그러나 한번에 여러가지 조건을 테스트 해야 하는 경우가 있다. 논리 연산자는 여러 조건을 테스트 할 수 있는 기능을 제공한다. C++에는 세가지 논리 연산자가 있다. Operator Symbol Form Operation Logical NOT ! !x true if x is false, or false if x is true Logical AND && x && y true if both x and y are true, false otherwise Logical OR || x || y true if ..

Sizeof Operator 어떠한 데이터형의 크기를 알고 싶을 때 사용. sizeof 연산자는 자료형 또는 변수를 가지고 크기를 byte 단위로 반환하는 연산자다. 특정 시스템에서 자료형의 크기를 결정하기 위해 C++은 sizeof라는 연산자를 제공한다. Opertator Symbol Form Operation Sizeof sizeof sizeof(type) sizeof(variable) Return size of type or variable in bytes C++ 기본 자료형의 크기 Category Type Size Range boolean bool 1byte true / false character char 1byte 영숫자 1문자 -128 ~ 127 unsigned char 1byte 1문자(부..
증감 연산자 increment / decrement operators Operator Symbol Form Operation Prefix increment (pre-increment) ++ ++x Increment x, then evaluate x Prefix decrement (pre-decrement) -- --x Decrement x, then evaluate x Postfix increment (post-increment) ++ x++ Evaluate x, then increment x Postfix decrement (post-decrement) -- x-- Evaluate x, then decrement x 전위 증감 연산자(prefix increment/decrement operator)는 ..

단항 산술 연산자 (Unary arithmetic operators) C++ 에는 단항 더하기(+), 단항 빼기(-) 두 가지 단항 산술 연산자(unary arithmetic operator)가 있다. 이 두 가지 연산자는 숫자 표현식의 음수 또는 양수 값을 반환한다. 단항 연산자는 피연산자를 하나만 취한다. Operator Symbol Form Operation Unary plus + +x Value of x Unary minus - -x Negation of x 이항 산술 연산자 (Binary arithmetic operators) 다섯 가지의 이항 산술 연산자(binary arithmetic operator)가 있다. 이항 산술 연산자는 연산자 왼쪽과 오른쪽에 피연산자를 취한다. Operator S..

연산자 우선순위 - 레벨 1이 가장 높은 우선순위, 레벨 17이 가장 낮은 우선순위, 우선순위가 높은 연산자가 먼저 평가된다. - 표현식의 평가 순서를 명확히 하려면 괄호 연산자( )를 사용하면 됨. 거듭제곱 연산 C++에서 ^ 연산자는 비트 XOR 연산자(Bitwise XOR operation)다. C++에서 거듭제곱 연산을 실행하려면 라이브러리를 #include하여 pow() 함수를 사용하면 된다. ex) 2의 3제곱을 표현하고 싶을 때 #include #include using namespace std; int main() { int x = std::pow(2,3); cout