The material presented in this guide covers the concepts emphasized on Test 2. It is meant to guide students studying and reviewing for Test 2; it is not guaranteed to be comprehensive. Actual test questions will differ from the examples given here. Students should use this guide in addition to other study activities (like reading Chapters 5-10, reviewing completed lab assignments, old quizzes, etc.) Knowledge of Chapters 1-4 is assumed, but the emphasis is on material in Chapters 5-10.
if/else
, switch
,
while
, do/while
,
and for
statements and the conditional operator
(?:
).
break
and
continue
sqrt
,
pow
,
time
,
toupper
,
tolower
,
rand
, and
srand
.
For example, given the function
func(3, 12)
?
Be able to write a C++ function given its specification. The code may involve any of the concepts in Chapters 2-10. Thus, in order to write the code you may need to:
For example, complete the following function named
is_reduced
that
accepts two integer parameters,
numerator
and denominator
. The
function returns true if numerator/denominator
represents a fraction reduced to lowest terms;
otherwise, it returns false if the fraction
numerator/denominator can be reduced. For example,
is_reduced(1, 2)
would evaluate to true, but
is_reduced(2, 4)
would evaluate to false.
Improper fractions are acceptable, but
the function
should return false whenever denominator
is zero.
Some questions may ask you to rewrite a section of C++ code given certain criteria. Your new code must behave the same way as the original code, but your code must comply with the specified criteria.
For example, rewrite the following code fragment so that the conditional operator is not used:
Also, take time to review all the code we have developed in class.
It has all been uploaded to the course repository on GitHub
(
https://github.com/halterman/124_F17).