CMSI 182 - Introduction to Computer Science
Week 5
Schedule
-
This week: finish chapter 3
-
Week 6: chapter 4
-
Week 7: Test 1
References
Biermann's class notes:
Review of Some Features of Pascal
To concatenate two strings s1 and s2 and produce a third string s3
s3 := s1 + s2;
To extract a substring s1 from a string s2
s1 := copy(s2, startingPosition, numberOfCharactersToExtract);
To find the length n of a string s1
n := length(s1);
To find the position p of a string s1 inside string s2
p := pos(s1, s2); { p = 0 if s1 not in s2 }
To format the output of a real number x
writeln(x : 10:2); { outputs value of x in a field 10 columns
wide with 2 digits to the right of the decimal point. e.g. bbbbb12.34
where b = blank }
To declare an array
type
myStringArrayType = array[1..100] of string;
var
s : myStringArrayType; { creates an array
of 100 variables called s[1], s[2], ..., s[100]. Each variable is
of type string. }
To define a subroutine
procedure myProc(var x, y : real; var i : integer);
var
j, k : integer; { internal variables }
begin
...
end;
To call a subroutine
myProc(w, 1.5, 8); { calls procedure myProc which has three parameters
}
Homework
Read
Chapter 4
Reminder
Homework #4 is due next Tuesday.
Ken Geddes Home Page |
CMSI
182 Index | Week 4 | Week
6
Last Modified February 10, 2000
kengeddes@earthlink.net