CSC 226

CSC 226 logo

Software Design and Implementation


T4: Fruitful Functions

Paired assignment T4 should be completed with a partner.  Please change facilitator/recorder pairs.  If you were the facilitator last time, please record this time.  If you were the recorder last time, please facilitate this time. 

The instructions

For the remainder of this teamwork, please use the following roles:
  • Facilitator: Reads the questions aloud, keeps track of time, and makes sure both partners contribute appropriately.
  • Recorder:  Fully contributes in discussions then records all questions and answers.
  • If there is a third partner, they should serve as a Quality Control Officer: Considers how the answers could be deeper, and how the team could work and learn more effectively.
All partners should create a Microsoft Word file called yourusername-t4.docx where yourusername is appropriately replaced. e.g. Mine would be pearcej-t4.docx
  • Facilitator and Quality Control Officer: Submitted file contains only the name of the assignment, and the names and roles of all team members. For example:
    • Teamwork T4 Fruitful Functions
    • Facilitator: Ashley Aiken
    • Recorder:  Jan Pearce
  • Submitted file contains only the name of the assignment, the names and roles of all team members, and answers to the questions.
    • Teamwork T4 Fruitful Functions
    • Facilitator: Ashley Aiken
    • Recorder:  Jan Pearce
    • Followed by answers to all of the following:
I. Area of Circle
  1. Using the "Forward>" button, step through each of the following steps of code in the box below, briefly explaining in your report what each of the 15 steps does and how the existence and value of each variable changes at each step. Label these as 1, 2, 3, ... , 15
  2. In which step does r_str first get a value? Where does this value come from?
  3. In which step does r_val first get a value? Where does this value come from?
  4. Describe the difference between the value stored in r_str and r_val after step 8 of the program.
  5. In which steps does radius exist as a variable? i.e. Where does this value first  come from?
  6. In which steps does result exist as a variable?  Where does this value first come from?
  7. What happens to  radius and result when the flow of execution returns to the main() function?
  8. In which step does area_val first get a value? Where does this value come from?
II. The modulus (%) operator
  1. Using the "Forward>" button, step through each of the 16 steps of code in the box below, briefly explain in your report what each step does and how the existence and value of each variable changes at each step. Label these 1, 2, 3, ... , 16
  2. In which steps do x  and y exit? Where do these values first come from?
  3. Explain why remainder = x % y followed by if remainder == 0 gives information about y going into x evenly.
  4. In which steps does the variable remainder exist? Where does this value first come from?
  5. Explain how the following code works: if is_divisible(n_val, d_val) in the way we would hope.

Be sure ALL team members submit files named yourusername(s)-t4.docx  before leaving the classroom. Also be sure all team members have exchanged these files before leaving the classroom.

Copyright © 2016 | http://cs.berea.edu/courses/CSC226/ | Licensed under a Creative Commons Attribution-Share Alike 3.0 United States License