You are on page 1of 3

ICS2O1 Review Topics

Ch.4 SIMPLE PROGRAMS Ch.7 CHARACTER GRAPHICS


Integers and real numbers Character locations in the execution
Arithmetic expressions window
Combining calculations and messages Creating a graphical pattern with
characters
Output of a series of items
Interactive graphics
A series of output statements
Diagonal lines and patterns
Ch.5 VARIABLES AND CONSTANTS Drawing in color
Declaring variables Background color
Names of variables Hiding the cursor
Inputting character strings Animation with graphics
Strings containing blanks Controlling the speed of animation
Mistakes in programs Pausing for user input
Inputting numbers
Ch.8 PIXEL GRAPHICS
Mistakes in data
Pixel positions in the execution window
Inputting real numbers
Plotting dots in the execution window
Constants
Changing the execution window size
Assignment of values to variables
Drawing lines
Understandable programs
Drawing circles and ellipses
Comments in programs
Animation
Ch.6 REPETITION Drawing arcs
Loops Plotting a mathematical function
Conditional loops Using text with pixel graphics
Comparisons Background color
Comparing strings Sound with graphics
Counted loops
Ch.9 SELECTION
Counting in multiples
Simple selection
Loops that count backwards
Three-way selection
Counted loops with exits
Multi-way selection
Random exit from loop
Case construct
Compound conditions
Commands for action
Selecting from a menu of commands

Input / Output Statements


put putItem {, putItem } [..]
get getItem {, getItem }

Declarations
const id [: dataType]:= initializing Value
var id{, id]: dataType [:= initializingValue]

Data types
int, real, string

Control Constructs
Any number of exit and exit when constructs can appear at any place inside
for .. end for constructs and loop .. end loop constructs.

FOR for [decreasing ] variable : startValue .. endValue


[ by increment ]
... statements ...
exit when expn ...
statements ...
end for

LOOP loop
... statements ...
exit when expn
... statements ...
end loop

IF if condition then
... statements ...
{ elsif condition then
... statements ... }
[ else
... statements ... ]
end if

CASE case expn of


{ label expn { , expn } :
... statements ... }
[ label :
... statements ... ]
end case

Graphics
maxx : int
Maximum value of x in current pixel graphics mode. For CGA, maxx = 319.
maxy : int
Maximum value of y in current pixel graphics mode. For CGA, maxy = 199
cls
Clears the screen and places cursor at point whose screen coordinates are (1, 1). In pixel
graphics mode, clears the screen and changes screen to current background color.
color (colorNumber: int)
Sets color for text to be displayed.
colorback (colorNumber: int)
Sets color of the background on which text is to be displayed.
colorback (colorNumber : int)
Sets current background color of text displayed. The default background color is white.
drawdot (x, y, color : int)
Sets a dot (pixel) of color at point (x, y).
drawline (x1, y1, x2, y2, color : int)
Draws a line in color from (x1, y1) to (x2, y2).
drawbox (x1, y1, x2, y2, color : int)
Draws a rectangle in color with sides parallel to the axes, bottom left corner at (x1, y1), and
upper right corner at (x2, y2).
drawfillbox (x1, y1, x2, y2, color : int)
Draws a filled in rectangle in color with sides parallel to the axes, bottom left corner at (x1,
y1), and upper right corner at (x2, y2).
drawoval (xCenter, yCenter, xRadius, yRadius, color : int)
Draws an oval in color with center at (xCenter, yCenter), horizontal distance to oval xRadius,
vertical distance yRadius.
drawfilloval (xCenter, yCenter, xRadius, yRadius, color : int)
Draws a filled in oval in color with center at (xCenter, yCenter), horizontal distance to oval
xRadius, vertical distance yRadius.
drawarc (xCenter, yCenter, xRadius, yRadius : int, initialAngle, finalAngle, color : int)
Draws a part of an oval whose specifications are given (as in drawoval) between two lines
from the center that make angles in degrees: initialAngle and finalAngle , as measured
counterclockwise from the three o’clock position as zero.
drawfillarc (xCenter, yCenter, xRadius, yRadius : int, initialAngle, finalAngle, color : int)
Draws a filled-in “piece of pie” shaped wedge whose specifications are given (as in drawoval)
between two lines from the center that make angles in degrees: initialAngle and finalAngle, as
measured counterclockwise from the three o’clock position as zero.
drawfill (xInside, yInside, fillColor, borderColor : int)
Starting from a point (xInside, yInside ) fills an area surrounded by borderColor with
fillColor
locatexy (x, y : int)
Changes the cursor position in pixel graphics (the cursor is not visible) to be in the nearest
character position to point (x, y).
delay (duration : int)
Causes a delay of length duration milliseconds. A delay of duration 500 is half a second.

Operators
This is a list of the operators available in Turing and their precedence.
Mathematical Operators
Operator Operation Result Data Type
+ Addition Same as Operands
– Subtraction Same as Operands
* Multiplication Same as Operands
/ Division Same as Operands
div Integer Division int
mod Modulo int
** Exponentiation Same as Operands
< Less Than boolean
> Greater Than boolean
= Equals boolean
<= Less Than or Equal boolean
>= Greater Than or Equal boolean
not= Not Equal boolean

Boolean Operators
Prefix not Negation boolean
and And boolean
or Or boolean

sqrt (r : real): real


Returns the positive square root of r, where r is a non-negative value

You might also like