CP104 Lecture Notes - Lecture 10: Code Reuse
hayjayshay and 38575 others unlocked
2
CP104 Full Course Notes
Verified Note
2 documents
Document Summary
A function is a group of statements that exist within a program for the purpose of performing a specific task. Easier facilitation of teamwork each member works on a different function. Function should be in a separate file from main program. Indentation in controls structure must have same amount of space. These are var i(cid:374) a fu(cid:374)(cid:272)tio(cid:374) he(cid:374)(cid:272)e lo(cid:272)al a(cid:374)d (cid:272)a(cid:374)"t (cid:271)e used (cid:271)y (cid:373)ai(cid:374) progra(cid:373). Can have same name in different functions as they are local var so in essence they are different var with same name. Where var can be seen ex inside function, outside function etc. Constants: defined in 1 place and used in func. Preconditions: what must be true about parameters for func to work. X1 x coordinate of 1st point on graph(float) [condition can be like (int != 0)] X2 x coordinate of 1st point on graph(float) y1 y coordinate of 2nd point on graph(float) y1 y coordinate of 2nd point on graph(float)