?????%201%20???????????%20(Introduction%20to%20C%20Programming%20Language) - PowerPoint PPT Presentation

About This Presentation
Title:

?????%201%20???????????%20(Introduction%20to%20C%20Programming%20Language)

Description:

1 (Introduction to C Programming Language) – PowerPoint PPT presentation

Number of Views:167
Avg rating:3.0/5.0
Slides: 39
Provided by: comps156
Category:

less

Transcript and Presenter's Notes

Title: ?????%201%20???????????%20(Introduction%20to%20C%20Programming%20Language)


1
????? 1???????????(Introduction to C
Programming Language)
2
??????????? (Programming Languages)
????????????? ??????????????????????????????????
??????????????? ?????? ????????????????????
? ????????????????? ?????????????????
??????????????
3
1.1 ?????????????????
?????? ?????????????????? ????? (Dennis Ritchie)
??????????????????????????? (UNIX)
???????????????????? DEC PDP-11 ?????????????????
??????????????
4
1.2 ???????????????????
  • ???????????????
  • ?????????????????????????????????
  • ??????????????????????? ???????????????? ?
    ???????? ???????? (Function)

5
??????????? 1.1
  • include ltstdio.hgt
  • void main( )
  • / Display message to standard output
    /
  • printf(My first program.)
  • ????????????????????
  • My first program.

6
?????? 1.1 ????????????????????????
Header
include ltstdio.hgt void main( ) /
Display message to standard output /
printf(My first program.)
Comment /.../
Statement
7
???????? 1.2
  • include ltstdio.hgt void main( ) /
    Display message to standard output /
    printf(My first program.)

8
???????? 1.3
  • include
  • ltstdio.hgt
  • void
  • main
  • (
  • )
  • / Display message to standard output /

9
  • ??????? 1.1 1.2 ???? 1.3 ??????????????????
  • ??????????????? ??????????? ????????
  • ???????????????????????????? (Indentation)
  • ??????????????????????????????????
  • ??????????????????????????????? (Space Bar)
    ????????? 3-5 ??

10
1.3 ???????????????????
  • ????????? ???????? ????????????????? ???
  • ????????????
  • ?????????????????
  • ???????????????
  • ?????????????????????????????????????????
  • ???????? ?????????? (Variable) ???????????????????
    ?????????????

11
1.3.1 ??????????
12
????????????? ??????????????? ??? 3 ????
  • ?????????
  • ?????????
  • ????????????????? (String)

13
??????????????? 10 ???? 125 0 -154
??????????????? 8 ?????????????? 0 ????
0377 0177 0000 01 ??????????????? 16
?????????????? 0x ???? 0X ???? 0XFF 0x14
0x4B?????????????? long ????????????? l ????
L ???? 123L 0437l 0x4FFL
????????? ???????????????? int, short, long,
unsigned int, unsigned short ??? unsigned long

14
????????? ??? ?????????????????????????
???????? ?????????????????????????????????
???????????????? float ??? double
  • ????????????????? ???? 12.524 0.1259 0.00001
  • ???????????????????????????? ???? 1.0E4
    12.432e-4 1E-4 2E3
  • ?????????????? float ???? 1.4321F 472.324f
  • ?????????????? double ???? 232.98D 1.2323d

15
????????????????? (String) ????????????????
char ????????????????? 1 ??????
???????????????????????????? char (Array of
char) ??????????????????????????????????
  • ????????????? ???? a W \a \t
  • ????????????????????????? \ ??????????????????????
  • ???? \a ??????????????
  • \t ?????????????
  • \n ????????????????????

16
1.3.2 ????????????
  • ??????
  • ???????????? ??????????
  • ????????
  • float score
  • int age
  • char ch
  • float width, height, length

17
?????????????
  • ??????????? a ??? z
  • A ??? Z
  • ??? 0 ??? 9 ??? _ (Underscore)???????????????
    ??
  • ?????????????????????????? _
    ????????????????????????????????? (Keyword)

18
?????? (Keyword)
  • auto double int struct
  • break else long switch
  • case enum register typedef
  • char extern return union
  • const float short unsigned
  • continue for signed void
  • default goto sizeof volatile
  • do if static while

19
????????????????????
  • ???????????????????
  • ??????????????????????? ??????????????????????????
    ???????
  • ?????????????????????????????? ???????????????????
    ????
  • ??????????????????? define ??????????????????????
    ?????????????
  • ?????????????????????????? ? ??
    ?????????????????????????????????????????????????
    ??????? _ ???????????? ???? totalScore ????
    total_score

20
??????????????????
  • salary _MAX
  • MONEY Average_score
  • x totalPage
  • recordno annual2001

21
??????????????????????????????????????????????
float dollar int my age integer
age int a. b. c char
ch float student-height float
1Score float score int score
22
???????? ??????????????????????????????? ??? int
sum0 float height0.0f
23
1.3.3 ???????????????????????????
  • ?????????????????????? ??? ???????? scanf( )
  • ???????????????????????????????????? printf( )
  • ???????????????????????????????
  • include ltstdio.hgt

24
1.3.3.1 ????????????
  • ??????
  • scanf ( ?????? , ????????????1, ??????????2,
    )
  • ???????????? ???????????????????????????
    ??????????????????????????????????

25
  • ???? ????????????????????????????????
  • ?????????
  • int month, year
  • scanf(d d, month, year)

26
????? 1.2 ?????????????????????????
  • d, i ??????????????????????????????????? int
  • ld ??????????????????????????????????? long
  • u ??????????????????????????????????????????
    unsigned
  • o ???????????????????????????????8
    ????????????????? unsigned
  • x ???????????????????????????????16
    ????????????????? unsigned
  • c ??????????????????? 1 ???
  • s ??????????????????
  • f ???????????????????????????????? float
  • lf ???????????????????????????????? double

27
  • ????????????????????
  • scanf(d/d/d, day, month, year)
  • ??????????????????????????
  • 20/7/2001
  • ?????????????????????????????? ????
  • scanf(2d2d4d, day, month, year)
  • ?????????????????????????????
  • 20072001

28
1.3.3.2 ???????????????
  • ??????????? printf( )
  • ??????
  • printf ( ?????? , ??????????1 , ??????????2 ,
    )
  • ?????????????????????????????????
  • ???????????????????????
  • ????????????????????????????????

29
  • ????
  • char name Mickey
  • int age 20
  • printf(s is d years old., name, age)

???????????????? Mickey is 20 years old.
30
  • ?????????????????????? ? ???????????
  • printf(Good morning.)

???????????????? Good morning
31
  • ???????? ?????????????????????????????????
  • 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
32
????? 1.3 ??????????????????????????
  • ?????? ?????????????????
  • d, i ???????????????????????????????? int
  • ld ???????????????????????????????? long
  • u ???????????????????????????????????????
    unsigned
  • o ??????????????????????????????? 8
    ????????????????? unsigned
  • x, X ???????????????????????????? 16
    ???????????????? unsigned
  • c ???????????????? 1 ???
  • s ???????????????
  • f ????????????????????????????? float
  • lf ????????????????????????????? double

33
  • ???????? printf( ) ??????????????????????????
  • ???????????????????????????????????????????????
  • ????
  • printf(The sum of 5d and 5d is 5s\n, a, b,
    ab)

????????????????????? The sum of 7 and 2
is 9
34
  • ????????
  • 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
35
?????????????????????????????
??????????????????????????????????????????????????
???????????
  • ??????????? 1.5 ?????????????????????????????????
    ???
  • include ltstdio.hgt
  • include ltconio.hgt
  • void main( )
  • clrscr( )

36
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")
  • printf("\nx", 15)
  • printf("\no", 15)

Computer
Com
Computer
Computer
Com
/ Hexa f /
/ Octal 17 /
37
100
  • 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
32.576200
32.58
32.58
32.58
38
  • ??????????? 1.6 ???????????????????????????
  • 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.
Write a Comment
User Comments (0)
About PowerShow.com