Ch.4 Flashcards
In the function declaration shown, the mechanism used to call this function is known as:
double pow(double base, double exp);
call by value
If you need to write a function that will compute the cost of some candy, where each piece costs 25 cents, which would be an appropriate function declaration?
int calculateCost(int count);
What is the value of the following?
sqrt(sqrt(pow(2,4)));
2
Using namespace std; tells the compiler
where to get the definitions of certain objects (variables).
What is the output of the following program fragment?
cout ≤≤ static_cast ≤ float > (3/4) ≤≤ endl;
0.0
What is the output of the following program fragment?
cout ≤≤ static_cast ≤ double > (3)/4 ≤≤ endl;
0.75
Information Hiding is analogous to using
a black-box methodology.
Which of the following functions is a properly overloaded function of the following?
int doSomething(int first, float second);
A) int doSomething(int first, int second, float third);
B) int doSomething( int next, float last);
C) int doSome(int first, float second);
D) float doSomething(int first, float second);
int doSomething(int first, int second, float third);
If the variable x has the original value of 3.4, what is the value in x after the following?
cout << static_cast < int > (x);
3
When the function below is called, the ________ of the actual parameters is passed to the function definition.
double sqrt(double value);
value
If you have the following variable declaration in your program,
const int SIZE = 34;
then which of the following statements are legal?
cout << SIZE;
The functions pow( ), sqrt( ), and fabs( ) are found in which include file?
cmath
When overloading a function, what must be true?
A) The names should be different with the same number and/or types of parameters.
B) The names should be the same with the same number and/or types of parameters.
C) The names should be different with different number and/or types of parameters.
D) The names should be the same with different number and/or types of parameters.
The names should be the same with different number and/or types of parameters
When parameters are passed between the calling code and the called function, parameters and arguments are matched by
their relative positions in the parameter and argument lists
If you have the two functions as shown,
int someFunction(int value);
float someFunction(float value);
and a variable x, which is a double, which function is called by the following statement?
cout ≤≤ someFunction(x);
Nothing, it is a syntax error.