Dr. Niklaus Wirth .. 2514 - PowerPoint PPT Presentation

1 / 48
About This Presentation
Title:

Dr. Niklaus Wirth .. 2514

Description:

????????????????? ... 2185 ?????????????????????????????????????? ... ?????????????? 1 ??? ??????????????????????? Single Quote ???? Apostrophes ... – PowerPoint PPT presentation

Number of Views:160
Avg rating:3.0/5.0
Slides: 49
Provided by: csS7
Category:

less

Transcript and Presenter's Notes

Title: Dr. Niklaus Wirth .. 2514


1
?????????????????
  • ????????????????????????????????????????
    ??????????? ???????????????? ??????(Dr. Niklaus
    Wirth) ???????????????????????????
    ???????????????????? ??????????????? ?.?. 2514
  • ??????????????????????????????????? ???? ??????
    (Blaise Pascal) ?????????????
    ???????????????????? (?.?. 2166-2205)????????????
    ????????????????????????????????????????? ?.?.
    2185 ??????????????????????????????????????
  • ??.???????? ???????????????? PL/1 ??? ALGOL-60
    ?????? ?????????????????????????????????????????
    ??????

2
???????????????????
  • ?????????????????????? ???????????????????????????
    ????? ???????????????????????????
    ??????????????????????????????????????????????????
    ?????????
  • ????????????????????????? ????????????????????????
    ???????????????????????????????
  • ???????????????????????????????????????
    ??????????????????????????????????????????????????
    ? ?????????????????? ????????????
    ????????????????
  • ????????????????????????????? ????????????????????
    ????????????????????????

3
????????????????????????????????
??????
Create/Edit Text File
pico ltfilenamegt.pas
Source Code
Machine Code
4
??????????????????????????????
  • ???????????????????
  • Syntax error
  • ?????????????????????????????????
  • ??????????????????????(compile)???????
  • ????????????????????????
  • ???? a10
  • writtln(a)

Writeln(a)
5
??????????????????????????????
  • Run-time error
  • ???????????????????????????????????????????????
  • ?????????????????????????????
  • ???? ?????? 1/x ??????????? xgt0 ??? x lt10
    ?????????????? 0 ????????????????????????
    Run-time (?????????????????????????????)
  • Logical error
  • ?????????????????????????????????
  • ??????????????????????????????????
  • ???? x b ????? x b/2a ?????????? x
    (b/2)a ??????????????? ???? x b/(2a)

2a
6
??????????????????????
PROGRAM ???????????
??????? (Heading)
LABEL VAR CONST TYPE
?????????? (Declarations)
PROCEDURE or FUNCTION
BEGIN
?????????? (Statements)
.
END.
7
Start
Read num1, num2,num3
avg(num1num2num3)/3
Write avg
Stop
8
?????????????????????????
PROGRAM example Calculate average of three
numbers CONST COUNT 3 VAR num1,
num2, num3 integer average
real BEGIN readln(num1, num2, num3)
average(num1num2num3)/count writeln(The
avarage is,average52) END.
???????
???? ??????
??????????
9
??????? (Heading)
  • ?????????????????????? ???????? ??????
  • PROGRAM ???????????
  • ????????????????????? PROGRAM ????????????????????
    ?? ????
  • PROGRAM Test
  • PROGRAM Calculate_Grade
  • PROGRAM Hello

????????????????? (?????????)
???????????????????
10
?????????? (Declarations)
  • LABEL ??????????????? ????????????????????????
    GOTO ?????? ??????????????
  • LABEL ???? ,????
  • CONST ??????????????? ???????????????????????
    ??????????????
  • CONST ???? ???????????
  • ???? CONST title TITANIC
  • max 200

11
?????????? (Declarations)
  • VAR ??????????? ????????????????????????????????
  • VAR ???? ,???? ?????????????
  • ???? VAR title string
  • max, min, avg integer
  • ?????????????????? variable ?????????????????????
    ????????

12
?????????? (Statements)
  • ???????? BEGIN ??? END ????????????????????????
    ????????? ? ??????????????????????????????????????
    ??????
  • ????????
  • PROGRAM hello
  • BEGIN
  • writeln(Hello! World)
  • END.

????????????????? . (full stop)
??????????????????? end
13
?????????????????
  • ???????????????? source code ???? hello.pas
    ???????????? pico hello.pas
  • ??????????????????
  • PROGRAM hello
  • BEGIN
  • writeln(Hello! World)
  • END.
  • ?????????????????????????????????? CtrlX
  • ?????????????????????????? gpc hello.pas
  • ?????????????????????? a.out

Hello! World gt
14
??????????? (Identifiers)
1. ????????????????????????? A ??? Z
????????????????? 0 ??? 9 ????????????????????
?????? ? ????
2. ????????????????????????????? (??????????????)
??????????? ??????????????? ????????
??????????????? Underline ( _ ) ?????
3. ??????????????? ????????????????????????
4. ????????????????????????????????? 255 ?????????
5. ?????????????????????????????????? (Reserve
Word)
15
?????? (Reserved word)
  • ??????????????????????????????????????????????????
    ???????
  • ?????????????????????????????????????????
    (Identifiers) ???
  • ?????????????????????????????????????????????? ?
    ????????????????????????????????
  • ????????
  • AND END NIL SET
  • ARRAY FILE NOT THEN
  • BEGIN FOR OF TO

16
?????? (Reserved word)
  • CASE FUNCTION OR TYPE
  • CONST GOTO PACKED UNTIL
  • DIV IF PROCEDURE VAR
  • DO IN PROGRAM WHILE
  • DOWNTO LABEL RECORD WITH
  • ELSE MOD REPEAT

17
????(Identifiers)
  • ?????????????? ?????????????????
  • R2D2O 2Bar02B
  • Pattittan FirstRun
  • Top40_Farrah Fawcett-Major

18
????????????? (Data Type)
  • ???????????????? (Simple-type data)
  • ???????????????? (Standard Data Type)
  • ??????????????????????? (User-defined Data Type)
  • ????????????????????? (Structured-type Data)
  • ???????????????? (Pointer-type Data)

19
????????????????(Standard Data Type)
1. ????????????????????? (integer) ???? 0 1 -1
-500 44 89
2. ????????????????????? (real) ???? 12.1 0.5 22/7
3. ??????????????? (char) ???? A 2
4. ?????????????? (string) ???? SILPAKORN SC
5. ??????????????????? (boolean) ???? ???? (true)
???? (false)
????????????????? ?????????????????? ???
?????????????????????????????
20
?????????????????? (integer)
  • ???????????????????????????
  • ?????? ???????????? ??????????? ?????
    ??????????????????
  • ??????????????? -32 768 ??? 32767
  • ???? 0 1 -1 1 -2225 12358


21
?????????????????? (real)
  • ???????????????????????? ???????????????????
    ????????? ??????????????????? ????????????????????
    ??????????
  • ???????????????? 1 x 10-38 - 1 x 1038
  • ???????????????????????????????? (Exponent)
    ?????????????? E ??????????????????????????
  • ???? 3x1010 ?????????????????????????? E
    ?????????
  • 3.0E10 3.0E10 3e10 3E10
  • 0.3E11 0.3e11 30.0E9 30e9

22
?????????????????? (real)
???? -7.026x10-17 ?????????????????????????? E
????????? -7.026E-17 -0.7026E-16 -70.26e-18 -0.000
7026e-13 ?????????????????????????????????????????
??? 9.E 10 5e2.3 .333e-3 4E 10 8.9 e4
????????????????????????
???????????????????????????
?????????????????????
?????????????? E
?????????????????? e
23
??????????????? (Character)
  • ?????????????? 1 ??? ???????????????????????
    Single Quote ???? Apostrophes( )
  • ??????????????? ?????? ???????????????????????
  • ??????????????????????????????????
  • ????????????
  • A , 2 , b , ,

24
?????????????? (String)
  • ????????????????? (characters) ???????????????????
    ????????????????? Single quote ???????????????????
    ????????? ? ???
  • ??????????????????????????????? 255 ?????????
  • ????
  • PASCAL PROGRAMMING
  • 270-32-222
  • 3(I4)/J
  • Shes a lovely girl

25
??????????????????? (Boolean)
  • ??????????????????????????? ??????????????????????
    ???????????????
  • ????? 2 ??? ???
  • True (????)
  • False (????)

26
???????? (Constants)
??????
????????
CONST PI 3.1415927 TAXRATE 0.07
BLANK MAX True
CONTINUE Press enter to continue..
27
?????? (Variables)
??????
????????
VAR radias, high real row, column
integer name string choice
char done boolean
28
Operator ??????????????????????
???????
Operand
????????
?????????
????????
integer
integer
A B

???
integer
integer
A - B
-
??
integer
integer
A B

???
real
integer
A / B
/
???
integer
integer
A DIV B
DIV
?????????
integer
integer
A MOD B
MOD
?????????
29
??????
  • ??????????????????????????????????
    ???????????????
  • ???? 4 ??????? 3 ??? 1.33333333333E
    00   ???????????????????? 4 ??????? 3 ??? 1 
    ?????? 1            ???????????????????????
  • ????????????????????? ????????????????????????????
    ???????????? ?????????????????????????????????????
    ???????

30
??????????????? (DIV)
  • ????????????????????????????????????????????
    ??????????????????? ??????????????????????????????
    ???????????????
  • ??????????????????????????? ??????????????????????
    ??????????? ???????????????????????????? 0
  • ????   15 DIV 2 7 (15/2 7.5)

9 DIV 5
1
2
24 DIV 9 
-19 DIV 5  
-3
1 DIV 5  
0
31
???????????? (MOD)
  • ??????????????????????? ??????????????????????????
    ???????
  • ?????????????????????????????????????????????
    ??????????????????????????????????????????????
    ???????????????????????????? 0
  • ???? 15 MOD 2 1 (15/2 7 ??? 1)      

  9 mod 5 
4
  24 mod 9
6
  9 mod 24 
9
32
??????????????????????????????
  • ??????????????????????????? (arithmetic-logic
    statement)
  • ???????????????????????? (input/output statement)
  • ??????????????????????????? (selection statement)
  • ?????????????? (looping statement)
  • ?????????????????????????????? (call subprogram)

33
??????????????????????????? (arithmetic-logic
statement)
????????????????? (Assignment Statement)
??? ???????????????????????????????????????????

??????
????????
Price100 tax0.07price
34
???????????????????????? (input/output statement)
???????????????????? (Output Statement)
?????????????????????????????????????????????
?????? ?????? Write , Writeln ????????????????????
?????? 2 ????? ???
1. ?????????? ???????? ????????????????
2. ??????????(char)????????????????(string)
??????
write(parameterlengthdecimal,...)
writeln(parameterlengthdecimal,...) writeln
35
?????????????????????? (Executable Statements)
??????????????????????? write ??? writeln
?????? writeln ??????????????????????????????????
?????????????????
x
y
????????
x 10 y 20
10
20
write(x) write(y)
10 20
num110 Write(num1102)
x 10 y 20
10.00
writeln(x , x) writeln(y , y)
36
??????????????????
  • ???????????????? source code ???? display.pas
    ?????????????????????
  • PROGRAM display
  • var x,y integer
  • BEGIN
  • x 10
  • y 20
  • write(x)
  • write(y)
  • END.
  • ???????????????????????
  • ????????????????????????????

write(x,y)
10 20gt
writeln(x,y)
writeln(x , x) writeln(y , y)
writeln(x) writeln(y)
10 20 gt
10 20 gt
x 10 y 20
37
?????????????????????? (Executable Statements)
??????????????????? writeln ??????? parameter
????????
x 10 y 20 sum x y write(x,
,y, ,sum)
10 20 30
x y sum
10 20 30
38
????????????????????? 1 ??????????????????????????
????????-????????????
  • ???????????????????????????????????????? 2 ???
    ???????
  • ?????(Summary)
  • ????(Different)
  • ?????(Multiply)
  • ?????(Devide)
  • ???????????? (DIV)
  • ??????????? (MOD)
  • ???????????????????????

39
?????????????????????? (Executable Statements)
????????????????????????? (Input Statement)
????????????????????????????????????????????
(keyboard) ???? ??????????????????????????
?????? ?????? Read , Readln
??????
????????
Read(number) Read(a,b,c)Readln(text)
Readln(x,y,z)
40
?????????????????????? (Executable Statements)
??????????????????????? read ??? readln
?????? readln ????????????????????? read ????
readln ???????? ????????????????????????????????(?
????????????????????????????)
????????
Read(number) Read(a,b,c)Readln(text)
Readln(x,y,z)
41
??????????????????????????????
  • ???????????????? source code ???? read.pas
    ?????????????????????
  • PROGRAM readwrite
  • var x,y integer
  • BEGIN
  • readln(x)
  • readln(y)
  • sum xy
  • write(xy, sum)
  • END.
  • ??????????????????????? ????????????
  • ????????????????????????????

read(x,y)
gt
write(Enter2 integer) readln(x,y)
write(Enter 2 integer) readln(x,y)
Enter 2 integer
42
???????????? (Operators)
  • ?????????????????
  • ????????? , -, , / , DIV, MOD
  • ????????? , -, , /
  • ?????????????????
  • ??????????????????????? , ltgt, lt, lt, gt, gt
  • ?????????????????? AND, OR, NOT

43
?????? (Expression)
?????????????? ???????????????? Operand
????????????? ???????? 1 ??????????????
????????????????????????????? ????????????????????
?????????????? Operator
???????????????????
???? ab/cd
???????????????????
???? row gt MAX MAX and Done
44
?????????????????????????????
1. ???????????????????????????????
2. ???????????????????????? ??????????????????????
?????????
3. ?????????????????????????????????????
??????
(??????) -(??????) NOT / DIV MOD AND -
OR ltgt lt lt gt gt
??????
4. ??????????????????????????????????
?????????????????
45
????????
2 6 / 3 3
2 (2 (2 3) 4)
4 2 1 3
3 1 2
8
28
46
????????
7 10 - 5 MOD 3 4 9
70 - 2 4 9
70 - 8 9 71
47
????????
2
1
7
6
5
4
3
8
42
2 ( ( 8 MOD 5 ) ( 4 ( 15 - 3 ) / sqr( -4
2 ) ) )
5 MOD 6
3
8 MOD 5
5
8 DIV 5
1
5 DIV 6
0
48
????????????????????? 2 ??????????????????????????
????????-????????????
??????????????????????????????????????????????????
? ???????????????????????????????????????????
???????????????
F 9C 32 5
Write a Comment
User Comments (0)
About PowerShow.com