Radhu2 Q.6 The function call below is designed to return, in variable result, th
ID: 673390 • Letter: R
Question
Radhu2
Q.6 The function call below is designed to return, in variable result, the product of x and y. All the variables are of type int. What is the correct prototype for such a function?
myFunction(result, x, y);
A. void myFunction(int &, int, int) ;
B. void myFunction(int, int, int) ;
C. void myFunction(const int *, const int, const int) ;
D. void myFunction(int *, const int *, const int *) ;
Q.7 If the function square(x) returns the square of x, then x should be passed by
A. value so it is protected (cannot be changed).
B. reference so it is protected (cannot be changed).
C. pointer so it is protected (cannot be changed).
D. None of the above. X cannot be protected; square can change the value of x regardless of how it is passed.
Q.8 Which of the following is an invalid declaration to overload the following function?
double foo(int);
A. double foo(double);
B. int foo(int);
C. double foo(double *):
D.double foo(int *);
Q.9 Which of the following statements call the following function correctly?
int MultiplyValues (int, int);
A.int a = MultiplyValues (int x, int y);
B. int a = MultiplyValues (10, 20);
C. double d = MultiplyValues (int 10, int 20);
D. All of the above
Q.10 A Distance class has two private members, ‘feet’, of type int, and ‘inches’, of type double. Which prototype correctly declares the copy constructor for such class?
A. Distance Distance(const Distance &);
B. Distance(const Distance &);
C.int Distance(int, double);
D. Distance(feet, inches);
Explanation / Answer
6) void myFunction(int *, const int *, const int *) ;
7) pointer so it is protected (cannot be changed).
8)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.