Title: ??. 217 ????????????? CS217 C programming language
1??????????????????????????????????
517 101 LAB - 5_2
2????????????(operator)
- ???????????? (operator) ?????????????????????????
??????????????????????????? ??????????????????????
?
- ???????????????????? (assignment operator)
- ??????????????????? (arithmetic operators)
- ???????????????????? (bitwise operator)
- ??????????????????????? (relational operator)
- ????????????????????? (logical operator)
- ????????????????? (special operator)
6. ????????????????? (special operator)
3- ????????????????????????????? ????????
??????????????? (operand) ????????????????????????
??????????????? 2 ??? ???????????????????????????
???????????????????? ????????????????????????????
??????????????????????????????
4???????????????????? (assignment operator)
- ?????????????????????????????????????????
- ?????????????????????????????????????????????????
??????????? - ?????? identifier ????????????????????? ???
expression ?????????????? ??????
??????????????????????????????? - ??????????????? ???????? ??????????????????????
- ???? x 50
identifier expression
5???????? ????????????????????????????????
a 3 x y delta 0.001 sum a b area
length width
- ????????????? ????????????????????? ??????????
- ???? int i, j, k,cost,fee
- i j k 100
- cost fee45
6??????????????????? (arithmetic operators)
- ?????????????????????????????????????????????????
??????????
7???????? ??????????????????????????????????
- 4 3 2
- 4 6
- 9 2 - 15/3 7
- 18 - 5 7
- 13 7
- 20
8?????????????????????
-(-5(8-1))(858)/4
-(-57)(408)/4
-(2)48/4
-212
10
9???????????????????????(relational operator)
- ????????????????????????? (condition statement)
???? if - ????????????????????????????
- ?????????????? character string ??????? function
?????????string - ???????????????????????? ?????????????
(???????????? 0) ???? ???? (???????????? 1
????????????????????????? 0)
???????? ???? C ????????????????? boolean (true
???? false) ??????????????? 0 ?????????????
10????????????????????????????? c
??????????? operator ???????????????????
???? ????????????????????
???????????????????????????? printf(value of
true d , 55) / ?? turbo c
????????? 1 / printf(value of false d,
5!5)
11 - lt lt gt gt ??????????????????????????????????
????????? ????????????????????????????????????????
????? ????????????????????????????????????????????
??????? - ! ?????????????????????(equality operator)
????????????????????????????????
?????????????????????????????????lt lt gt gt
???????? ????????????????????????????????????????
?????
12???????? 1
- ????? i, j ???k ??????????????????????????? 1, 2
???3 - ???????? ?????????????????????????????????????????
???????
13????????????????????? (logical operator)
- logical operator ??? ????????????????????????????
????????????????? ????????????????????? 2
???????????????????????? ?????????????????????????
??????????? 2 ???? ??? ?????????????????? 1
????????????????????? 0 ?????????????????????????
??????????(relational operator)
???????????????????????? (logical operator)
????????
14????????????????????? (logical operator)
15??????????????????? operator ???
???????? ?????? operand ??????? 0 ?????? ????
????????????????????? 0 ?????????? ???????? prin
tf(value of (2gt5) (5gt5) d , (2gt5)
(5gt5)) printf(value of (2gt5) (5gt5)
d , (2gt5) (5gt5))
16????????????????? (special operator)
- ??? ??????????????????????????????????????????????
? - ????? ????????????? ??????????????
- ?????????????????/?? (increment/decrement
operator) - ?????????????????????? (pointer-related
operators) - ?????????????????? (comma operator)
- ????????????????????? (cast operator)
- ?????????????????? (sizeof operator)
17?????????????????/?? (increment/decrement
operator)
- ??????????????????????????????????????????????????
??????????????
- ????????????????????????????? 2 ?????? ???
181. ???????????????? ???? i ???? i--
- ????????????????? operator ???????????
????????? ??????????????????????
- ???? count 2
- i count
- ?????????????????????? count ??????????? i ????
- ??????????????????????? count ????????????
- ????? i ???????????? 2
- count ???????????? 3
192. ???????????????? ???? i ???? --i
- ?????????????????????????????????????????
????????? operator ???????
- ???? count 2
- i count
- ????????????????????????? count ????????????
?????????????? - ????????? i
- ????? i ???????????? 3
- count ???????????? 3
20 ?????????????????? (comma
operators)
- ??????????????????? ????? statement ????????
- ???????????? int i 5, j 6 , k
21 ????????????????????? (cast operator)
- ?????????????????????????????????????????????????
??????????????????????????????????
????????????????????????? - ????????????????????????????????????????????????
??????????? ??? -
-
- ???????? type ????????????????????????????????????
????? expression ????????????????? ????
expression ????????????????????????
(type) expression
22- float cost3.5
- int mycost cost / mycost ???????????? 3
/ - ??????? ???? c ????????????????????????????????
?? - ??????????????????????????????????????????????????
?????? - casting operator ????
- i (int) 3.4 6
- i (int) (3.46)
-
23Compound assignments
- ????????????????????????????????????????
????????????????????? - ???????????? ????
- ??????????????????? C ???????????? operator
?????????????????? ??????????? compound
assignments ?????????????????????????????????????
?? operator ?????????? compound assignment
??????????
int i 5 i i 5 / i ??????? 10 /
??? ???????????????????????? i ??????? 5
????????????????????????????????? i ????????
24??????????????????? compound assignments
25???? ????????????????? operator
?????????????????
??????????????????