














Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The notes from lecture 7 of an introductory computer science course. The lecture covers developing algorithms using nested loops, with examples of nested stars and a times table. The students are also introduced to the concept of prime numbers and writing a program to determine if a number is prime.
Typology: Study notes
1 / 22
This page cannot be seen from the preview
Don't miss anything!















February 10, 2009
Lecture 7^
Special Introductory Offer:Just 1 correct answer
for full credit!
February 10, 2009
Lecture 7^
Example: Nested Stars
February 10, 2009
Lecture 7^
February 10, 2009
Lecture 7^
February 10, 2009
Lecture 7^
x=0;^
y=0;^
%^ figure
centered
at^ (0,0)
s=^ 2.1;
side^
length
of^ square
DrawRect(x-s/2,y-s/2,s,s,’k’)r=^ 1;
k=^
while
r^ >
%r^ still
big
%^ draw
a^ star if^ rem(k,2)==
%odd
number
DrawStar(x,y,r,’m’)
%magenta
elseDrawStar(x,y,r,’y’)
%yellow
end%^ reduce
r r=^ r/1.2;k=^ k^
end
February 10, 2009
Lecture 7^
February 10, 2009
Lecture 7^
February 10, 2009
Lecture 7^
February 10, 2009
Lecture 7^
February 10, 2009
Lecture 7^