Title: ????? 1 ??????????? (Introduction to C Programming Language)
1??????????????????????????????????
2????????????
- ??????
- scanf ( ?????? , ????????????1,
??????????2,..) - ??????????????????????????????????????
- ?????????????????????????????
????????????????????? - ????????????????????? ?????? (Format code)
????????? - ?????????????????????????????????????
3- ?????????? (formal code)
- d ???????????????????? integer
- ld ???????????????????? long
- c ???????????????????????
- s ??????????????????????? (string)
- f ???????????????????????????????
4?????? (Format code)????????????
- ?????? ?????????????????
- d, i ????????????????????????????????
int - ld ???????????????????????????????? long
- u ???????????????????????????????????????
unsigned - O ??????????????????????? 8
????????????????? unsigned - x, X ??????????????????????? 16
???????????????? unsigned - c ???????????????? 1 ???
- s ???????????????
- f ????????????????????????????? float
- lf ????????????????????????????? double
5????????????????????????
- ????????????????? ??? Format code ??????
- ????
- d s ?????? ??????????????????????
- ?????????????????????????????????????????
- ???????????????????????????????????????
6- ????
- ????????????????????????????????
- ?????????
- int month, year
- scanf (d d, month, year)
7- ????????????????????
- scanf (d/d/d, day, month, year)
- ??????????????????????????
- 20/7/2001
-
- ?????????????????????????????? ????
- scanf(2d2d4d, day, month, year)
- ?????????????????????????????
- 20072001
8????????????????????????????????
printf
- printf (?????????)
- printf (??????,??????????1,??????????2,.. )
- ????
- Control?????????? ???????????????/??????(Fo
rmat code) ?????????????????????
????????????????????????????????? - ???????????????????????????????????????????????
????????
9???????? printf
?????? printf (?????????) printf
(??????,??????????1,??????????2,.. )
???? printf ("One 1 two 2") printf ("One d two d", 1, 2)
10- ?????????? (formal code)
- d ???????????????????? integer
- ld ???????????????????? long
- c ???????????????????????
- s ??????????????????????? (string)
- f ???????????????????????????????
- ????????
- printf(One d Two d,
1,2) - ???????????????
- One 1 Two 2
11?????? (Format code)????????????
- ?????? ?????????????????
- d, i ????????????????????????????????
int - ld ???????????????????????????????? long
- u ???????????????????????????????????????
unsigned - O ??????????????????????? 8
????????????????? unsigned - x, X ??????????????????????? 16
???????????????? unsigned - c ???????????????? 1 ???
- s ???????????????
- f ????????????????????????????? float
- lf ????????????????????????????? double
12- ????
- char name Mickey
- int age 20
- printf(s is d years old., name, age)
-
???????????????? Mickey is 20 years old.
13- ?????????????????????? ? ???????????
- printf(Good morning.)
???????????????? Good morning.
14- ???????? ?????????????????????????????????
- int x, y
- x 7
- y 2
- printf(The sum of d and d is d\n, x, y,
xy) -
???????????????? The sum of 7 and 2 is 9
_
15- ???????? printf( ) ?????????????????????????
- ????????? ????????????????????????? ?????????????
- ????
- printf(The sum of 5d and 5d is 5d\n, a, b,
ab)
????????????????????? The sum of 7 and 2
is 9 _
16???????????????????????????????????
- ????????????? ????????????????????????????????
?????????? ??????????? - ??????????? ?????????????????????
- ????????? ???????????????????????
????????????????????????????????? - ????????????????????????????????????????? ???
Format code
17- ????????
- float x43.34, y2.231
- printf(Minus f with f, answer is f, x, y,
x-y) -
-
-
-
????????????????????? Minus 43.340000 with
2.231000, answer is 41.109000
??????????? printf(Minus 4.2f with 4.2f,
answer is 4.2f)
????????????????????? Minus 43.34 with 2.23,
answer is 41.11_
18?????????????????????????????
??????????????????????????????????????????????????
???????????
- ???????? ????????????????????????????????????
- include ltstdio.hgt
- include ltconio.hgt
- void main( )
- clrscr( )
19 Computer
- printf("\ns", "Computer")
- printf("\n2s", "Computer")
- printf("\n.3s", "Computer")
- printf("\n10s", "Computer")
- printf("\n-10s", "Computer")
- printf("\n-10.3s", "Computer")
- printf("\n")
-
-
Computer
Com
Computer
Computer
Com
20- printf("\nd", 100)
- printf("\n.2d", 100)
- printf("\n10d", 100)
- printf("\n-10d", 100)
- printf("\n-10.2d", 100)
- printf("\nf", 32.5762)
- printf("\n.2f", 32.5762)
- printf("\n10.2f", 32.5762)
- printf("\n-10.2f", 32.5762)
100
100
100
100
100
32.576200
32.58
32.58
32.58
21- ???????? ???????????????????????????
- include ltstdio.hgt
- void main( )
- char name100
- printf("What is your name ?\n")
- scanf("s", name)
- printf("Very glad to know you, ")
- printf("s.",name)
-
-
-
?????????????????? What is your name
? Willy Very glad to know you, Willy.
22????????? getch()
- ????????? getch() Â ???????????????????????????????
?????? 1 ??? ???????????????????? - include ltconio.hgt
- void main( )
- clrscr( )
- printf (Good morning )
- getch()
23?????????
- ??????????????????? ??????? ??? ???????
???????(???????) ??????????????????? - ??????????????????? ??????????
- ?.?. ?????????? ½ ??? ???
- ??????????????????????? 5 ???????????????????
???????????????????