Title: ???????? Dr.Niklaus Wirth ?? 2513
1??????????
- ???????? Dr.Niklaus Wirth ?? 2513
- Pascal ????? Blaise Pascal ???????????????????????
? - ????????????? Algol60 ??? PL/1
- ?????????????????????? (Structured Programming)
2??????????????????????
PROGRAM ???????????
Heading
VAR LABEL CONST TYPE
Declarations
PROCEDURE or FUNCTION
BEGIN
Statements
.
END.
3?????????????????????????
PROGRAM example(input,output) Calculate
average of three numbers CONST COUNT
3 VAR input1, input2, input3 integer
average real BEGIN readln(input1,input2
,input3) average(input1,input2,input3)/count
writeln(The avarage is,average52) END.
???????
???? ??????
??????????
4????????????????????????????????
??????
Create/Edit Text File
pico ltfilenamegt.pas
Source Code
Machine Code
5???????????(Identifiers)
1. ????????????????????????? A ??? Z
????????????????? 0 ??? 9 ????????????????????
?????? ? ????
2. ????????????????????????????? (??????????????)
??????????? ??????????????? ????????
??????????????? Underline ( _ ) ?????
3. ??????????????? ????????????????????????
4. ????????????????????????????????? 255 ?????????
5. ?????????????????????????????????? (Reserve
Word)
6????????????? (Data Type)
- ???????????????? (Simple-type data)
- ???????????????? (Standard Data Type)
- ??????????????????????? (User-defined Data Type)
- ????????????????????? (Structured-type Data)
- ???????????????? (Pointer-type Data)
7????????????????(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)
????????????????? ?????????????????? ???
?????????????????????????????
8???????? (Constants)
??????
????????
CONST PI 3.1415927 TAXRATE 0.07
BLANK MAX True
CONTINUE Press enter to continue..
9?????? (Variables)
??????
????????
VAR radias, high real row, column
integer name string choice
char done boolean
10???????????? (Operators)
- ?????????????????
- ????????? , -, , / , DIV, MOD
- ????????? , -, , /
- ?????????????????
- ??????????????????????? , ltgt, lt, lt, gt, gt
- ?????????????????? AND, OR, NOT
11?????? (Expression)
?????????????? ???????????????? Operand
????????????? ???????? 1 ??????????????
????????????????????????????? ????????????????????
?????????????? Operator
???????????????????
???? ab/cd
???????????????????
???? row gt MAX MAX and Done
12?????????????????????????????
1. ???????????????????????????????
2. ???????????????????????? ??????????????????????
?????????
3. ?????????????????????????????????????
??????
(??????) -(??????) NOT / DIV MOD AND -
OR ltgt lt lt gt gt
??????
13????????
7 10 - 5 MOD 3 4 9 70 - 2
4 9 70 - 8 9
71
14????????
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
15??????????????????????????????
- ??????????????????????????? (arithmetic-logic
statement) - ???????????????????????? (input/output statement)
- ??????????????????????????? (selection statement)
- ?????????????? (looping statement)
- ?????????????????????????????? (call subprogram)
16??????????????????????????? (arithmetic-logic
statement)
????????????????? (Assignment Statement)
??? ???????????????????????????????????????????
??????
????????
Price100 tax0.07price
17???????????????????????? (input/output statement)
???????????????????? (Output Statement)
?????????????????????????????????????????????
?????? ?????? Write , Writeln ????????????????????
?????? 2 ????? ???
1. ?????????? ???????? ????????????????
2. ??????????(char)????????????????(string)
??????
write(parameterlengthdecimal,...)
writeln(parameterlengthdecimal,...) writeln
18?????????????????????? (Executable Statements)
??????????????????????? write ??? writeln
?????? writeln ??????????????????????????????????
?????????????????
num1
num2
????????
num110 num220 writeln(Num1 ,
num1) writeln(Num2 , num2)
10
20
10 20
num110 Write(num1102)
Num1 10 Num2 20
10.00
19?????????????????????? (Executable Statements)
??????????????????????? write ??? writeln
????????
num110num220 sumnum1num2 Write(num1,
,num2, ,sum)
10 20 30
Num1num2sum 10 20 30
20????????????????????? 1 ??????????????????????????
????????-????????????
- ???????????????????????????????????????? 2 ???
??????? - ?????(Summary)
- ????(Different)
- ?????(Multiply)
- ?????(Devide)
- ???????????? (DIV)
- ??????????? (MOD)
- ???????????????????????
21?????????????????????? (Executable Statements)
????????????????????????? (Input Statement)
????????????????????????????????????????????
(keyboard) ???? ??????????????????????????
?????? ?????? Read , Readln
??????
????????
Read(number) Read(a,b,c)Readln(text)
Readln(x,y,z)
22?????????????????????? (Executable Statements)
??????????????????????? read ??? readln
?????? readln ????????????????????? read ????
readln ???????? ????????????????????????????????(?
????????????????????????????)
????????
Read(number) Read(a,b,c)Readln(text)
Readln(x,y,z)
23????????????????????? 2 ??????????????????????????
????????-????????????
??????????????????????????????????????????????????
? ???????????????????????????????????????????
???????????????