Study Guides (238,074)
Canada (114,908)
CS 115 (13)

Module 1 - Module 5 The notes combines the lecture notes and the useful information in the textbook. It covers module 1 through to module 5 with all definitions, operations and examples you need.

19 Pages
Unlock Document

University of Waterloo
Computer Science
CS 115
Sandy Graham

Computer Science 115By Ella ChenHow to Design ProgramsCourse Notes Module one Introduction to CS 115Section 2 Numbers Expressions Simple Programs21 Numbers and ArithmeticEvery Scheme expression is in the form operation ABExamples on mathematical operationssqrt A square root of Aexpt A B ABremainder A B remainder of ABquotient A B quotient of ABlog A natural logarithm of Asin A sine of A radians22 Variables and ProgramsDefining fuctions in mathematcsdefine functionname variable1 variable2 expressionEg define areaofcircle r314r rCharacteristics of fuctionsChanging names of parameters does not change what the function doesThe same parameter name can be used in different functionsThe order of arguments must match the order of the parameters in the definition of the functionDefining constantsdefine k 3 k3define pk k after define k 3k k gives 9 and p is bound to 9Using substitutiondefine f xx x defines function f which consumes one numerical valuedefine g x y x y defines function g which consumes two numerical valuesgf 2g 3 1 in the form of g x y and xf 2 and yg 3 1Tracing a programA stepbystep simplification by applying substitution rulesEg define term x yx sqr y term5 31 2term 21 2term 2 3 2 sqr 3 2 918The data type image you need the worldrkt teachpack use data type other than numbers define image1 rectangle 35 50 solid red define image2 circle 10 solid blue overlay image1 image2The data type Potatohead ph you need the potatoheadrkt teachpack defines a head with the following attributescolour size of the outer circleleft eye type left eye colourright eye typeright eye colourmouth type mouth colour the function consumes both numbers for size and symbols for types and coloursEND OF MODULE ONEModule 2 The Design RecipeSection 2 Numbers Expressions Simple Programs25 Design RecipeComments information important to humans but ignored by the computer Compared with CODE code is anything that is not a comment machinereadable starts a line that is a comment indicates that the rest of the line is commentThree Comment Components of Design Recipe Contract a formal description of what type of arguments the function consumes and what type of value it produces functionname type1 type2 type3typektypeproduced
More Less

Related notes for CS 115

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.