C

#7 (C) Operators(연산자)

tommy12 2022. 9. 15. 13:42
Operators(연산자) Operators’ functions (기능)
= Assign the value on the right side of the operator to the variable on the left side of the operator.

연산자 오른쪽에 있는 값을 연산자 왼쪽의 변수에 대입.
+ Add the both assigned operands.

주어진 피연산자들을 더함.
- Subtract the assigned value of the operand on the right side from the assigned value of the operand on the left side.

왼쪽의 피연산자의 값에서 오른쪽의 피연산자의 값을 뺌.
* Multiply the assigned operands.

주어진 피연산자들을 곱함.
/ Divide the assigned operand on the left side by the assigned operand on the right side.

왼쪽의 피연산자를 오른쪽의 피연산자 값으로 나눔.
% Get the remainder after dividing the assigned operand on the left side by the assigned operand on the right side.

왼쪽의 피연산자를 오른쪽의 피연산자 값으로 나눴을 때, 얻게 되는 나머지의 값을 구함.

 

 

a=a+b = a+=b
a=a-b = a-=b
a=a*b = a*=b
a=a/b = a/=b
a=a%b = a%=b

 

 

+ Operator - Operator
Examples Examples
int num1 = +1;
num1 = -num1;
num1 will be -1.
int num2 = -2;
num2 = -num2;
num2 will be +2.

 

 

Operator Operators’ functions
++a Increasing the value by 1, and then do the rest
a++ Proceeding the function and then increase the value by 1
--a Decrease the value by 1 and then do the rest
a-- Proceeding the function and then decrease the value by 1

 

 

Operators Operators’ functions
a>b, a is bigger than b
b<a, b is smaller than a
== a==b, a and b are the same
!= a!=b, a and b are not the same
<= a<=b, a is smaller than b or a and b are the same
>= a>=b, a is bigger than b or a and b are the same.

 

 

Operators Operators’ functions
&& AND, if a and b are all true, return true
|| OR, if one of a and b is true, return true, else false
! NOT, if a is true, return false. If a is false, return true