CS 1044 Homew ork 5 Summer I 2007
1
Instructions: This homework ass ignment focuses pr imarily on C++ functions. The answers to the following questions can
be determined from Chapters 3 through 9 of the lec ture notes and Chapters 2 through 8 of the text. As sume
any #include directives, var iable declarations, etc, which are needed to make the given code syntactically
correct. Submit your answers to the Curator collection point HW5.
1. Given the function prototype and declarations:
float Fix(int& N, float X);
int someInt = 10;
float someFloat = 4.3;
which of the following function calls would be syntactically correct?
1) Fix(someInt, 6.85);
2) someFloat = Fix(24, 6.85);
3) someFloat = 0.3 * Fix(someInt, 6.85);
4) Fix(someInt + 5, someFloat);
5) all of the above
6) 1 and 3 only
7) 2 and 4 only
8) None of these
2. For the function def inition
void Func( int& Gamma ) {
Gamma = 245;
}
which of the following comments best describes the direction of data flow for Gamma?
1) one-way, into the function
2) one-way, out of the function
3) two-way, into and ou t of the function
4) None of these
3. For the function def inition
void Func( int Gamma ) {
cout << 3 * Gamma;
}
which of the following comments best describes the direction of data flow for Gamma?
1) one-way, into the function
2) one-way, out of the function
3) two-way, into and ou t of the function
4) None of these
4. For the function def inition
void Func( int& Gamma ) {
Gamma = 3 * Gamma;
}
which of the following comments describes the dire ction of data flow for Gamma?
1) one-way, into the function
2) one-way, out of the function
3) two-way, into and ou t of the function
4) None of these