CS1112
Review Questions for Prelim 2
- Be sure to review all the lecture examples, section/lab
exercises, and homework problems!
- M exercises: You should complete all the
exercises in FVL labelled M at the end of each section. These
exercises are variations on the main example in each section and help
make sure that you actually understand the examples.
- Questions from Insight:
- P4.1.5, P4.1.6, P4.1.11
- P4.3.3
- P5.1.9
- P6.1.15,P6.1.19(a)
- P6.2.8
- Question 1
Part A:
Write a function hms2s that converts a time expressed in hours,
minutes, seconds to a time expressed in seconds. Function hms2s
returns one variable seconds and takes three input arguments:
hours (h), minutes (m),
and seconds (s).
Part B: Write a function s2hms that performs the
opposite operation. Function s2hms takes one input argument
seconds and returns three variables: h,
m, and s.
Part C: Write two function calls to the above functions (in a script).
Use input values of your choice.
- Question 2
Write a fragment to plot the function f(x) = 0.2*(x^3-x)/(1.1+cos(x))
for -2pi <= x <= 2pi.