`
Sequence
Selection
false true
Repetition
(false) (true)
.
if
.
if x 2
(true) if 2 x=4
(false) if 2 x= 0
1
`
IF
8/2=0
5/2
mod
x mod 2 X
X
X=0 X
X>0
X<0
2
`
Z
Z>30 Z
Z<30
H
H>35 H
H<15
3
`
Relational Operators)
4
`
<= >= 6
>=
<=
30
A
IF A>=30 A
27==27
5
`
False True
NOT ,XOR ,OR , AND
AND
True True False ( ) AND
True
6
`
OR 2
False False True ( ) OR
False
XOR 3
False
True
NOT 4
.True False False True
B,A
False
7
`
B=3,A=5
True B A
Fals
FALSE 5<3 TRUE 5>3
< A TRUE 5 3
NOT A , NOT B B FALSE
NOT A= False
NOT B=True
8
`
. True A<=B B=4 A=3 -
. -
. Flase A AND B B=false A=true -
if (x>0) 1
X X 1
if (x>10) if (x<>0) if (x>=0)
9
`
IF(8>6) Z IF(Z >6)
a==b a=b .1
a=b
b=4 a=b a=4
10
`
a==b
true b a
false
true a==b b=4 a=4
False b=5 a=4
11
`
if then else if then
If Then 1
If Then Else 2
Select Case 3
(if then)
(true Condition
If Then
statement s (
End if
12
`
<< >> x )
Read x
If (x=2) then
Print << >>
End if
Average 8
<< >>
Read average
If (Average>=90) then
Print << >>
x
(
Input x=2
If (x 0) then
ositive
End if
((if than Else))
if
If then
statement s)
Else
statement s)
End if
13
`
Read x
If (x> =50) than
Else
End if
Input x=2
If (x>0) then
is positive
Else
End if
if ..then ..else
Input Age
If (Age >= 18) Then
print The person has the right to vote "Else
Print The person has no right to vote
End If
14
`
Nested Selection Structure
17
If...Then.. Else If...Then... Else
if then else 1
Select Case 2
((if than Else))
.if then
15
`
if then else if
n
z x, y
Y X
z = Sqr(x) + Sqr(y)
Read x
Read y
If (x > 0) Then
If (y > 0) Then
z = Sqr(x) + Sqr(y)
Print «z=»; z
Else
« Print can not compute z »
End If
End If
16
`
z y x
can not compute z y x
z
Grade
average
If average > 75 Then
«print A»
Else If average > 65 Then
«print B»
Else If average > 55 Then
«print C »
Else If average > 45 Then
«print S»
«print F» Else
End If
((Select Case))
if then
if then else
17
`
Select Case
Case 1
Statement 1 )
Case 2
Statement 2 )
..
..
Case Else
Statement n
End Select
Grade
Select Case Grade
Case 90 To 100
Result
Case 80 To 89
Result
Case 70 To 79
Result
Case 60 To 69
18
`
Result
Case Else
Result
End Select
Select Case
Select Case Student
Case 1 To 25
Result A
Case 26 To 50
Result B
Case 51 To 75
Result C
Case 76 To 100
Result D
End Select
19
`
Scratch
Scratch
Scratch
(if then) 1
(if then else
Operators
20
`
100 < A > 0
A=100 A=0
Scratch
YES
NO YES
21
`
Scratch
Scratch
C=9 B=1 A=6
A B, C 1
22
`
) A B, C A if then : -2
A (
B C B if then else :
C
Scratch
1
-
if then else :
else
23
`
Scratch B=false A=true
. A OR B
.B=false A=true
OR
24
`
Scratch
Female F Male M
F M 1
25
`
. True if(x>=10) X=12 -
Flase If(A>=B) b=20 A=10 -
True If(A=B) B=C A=C -
Read A
Read B
if(A>B Larger
Else if
(A<B
End if
26
`
if then else
.if then if then else
if then.. Else
27
`
.1
if then else Scratch
Scratch
28
`
i jk x=15
x=15
i=0
j=0
k=0
if (( x >= 5) and (x <= 10))
i=i+1
Else if (( x <= 15) and (x <= 25))
j=j+1
Else
k=k+2
0 0 2
29