What Does This Program Do in ACSL?
DR. QIONG CHENG�COMPUTER SCIENCE DEPARTMENT
UNIVERSITY OF NORTH CAROLINA AT CHARLOTTE
1
Copyright © 2021by Qiong Cheng
Motivation
2
ACSL - What Does This Program Do in ACSL?
3
Understanding ACSL Pseudo-code
4
Constructs Used in the ACSL Pseudo-code
5
Constructs Used in the ACSL Pseudo-code
6
Constructs Used in the ACSL Pseudo-code
7
Operators
8
in that order of precedence
high
low
Operators
9
in that order of precedence
high
low
Expression:
Arithmetic expression: (2 + 3 * 4)/2 + 3^2 + 2 ↑ 3 + 7 % 3
Logical expression:
- using comparison operators (>, <, >=, <=, !=, ==)
3 < 5, 3!= 5
- using logical operators (!, && (and), || (or))
! (3!=5)
(3 < 5) && (3!=5)
(3 < 5) || (3!=5)
Functions
10
Functions
11
Functions
12
Functions
13
Functions
14
Functions
15
Functions
16
Statements
17
Sequential Statements
18
Appearing in Contest 1
Decision Statements
19
DIM A AS INTEGER�INPUT A�IF A > 35 THEN� PRINT (A + 2)�ELSE� PRINT (A - 2)�END IF�END
DIM A AS INTEGER�INPUT A�IF A > 35 THEN PRINT (A + 2) ELSE PRINT (A - 2)�END
Appearing in Contest 1
Practice
20
Practice
21
Practice
22
Practice
23
Loopings
The FOR loop in BASIC is an example of a repetition statement. It allows a set of statements to continually be executed over and over again for a specific number of iterations. A loop variable is used after the keyword FOR and "lower" and "upper" bounds are specified. On the last line of the loop the keyward NEXT is followed by the loop variable. By default, the loop variable increments by one each time the loop iterates. When the loop variable equals the upper bound it iterates one more time. Then, the loop variable increments but the loop does not iterate and the rest of the program (below/after the loop) executes.
24
DIM A AS INTEGER�FOR A = 1 TO 5� PRINT A�NEXT A�END
DIM A, B AS INTEGER�B = 5�FOR A = 1 TO 10� IF A + B >= 12 THEN PRINT "GREATER"�NEXT A�END
Appearing in Contest 2
Arrays
25
Appearing in Contest 3
Strings
26
Appearing in Contest 4