Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi this is for my computer engineering class and its a practice exam from last s

ID: 3807122 • Letter: H

Question

Hi this is for my computer engineering class and its a practice exam from last semester we're supposed to use to study, but he didn't add the solutions. Please Help!

If you could please explain how you acquired your answer that would be great!

P.S. there can be more than one answer!

10. The following code fragment invokes (calls) a void function named InitToZero: int alpha [20] ll returns alpha with every element of the array set to 0 InitTozero (alpha Which of the following is a valid function heading for InitToZero? A) void InitToZero( const int beta) B) void InitTozero (int betal201) C) void lnitTozero( int 1201) D) None of These 11. For the function InitToZero described above in Problem 10, which of the following would be an appropriate function prototype? A) void InitTozero( const int 120U); B) void InitTozero const int C) void InitTozero( int [J); D) None of These Page 3 of 11 November 17, 2016 Exam III (100 pts CPE 112 Fall 2016 12. Which of the following correctly compares the memory addresses contained in the pointer variables intPtr1 and intPtr2 IftintPtr1 "intPtr2) 13. Suppose that typedef int MatrixTypelMAXROWSULMAXCOLSU, has been used to create a two-dimensional array matrix data type called MatrixType. Which of the following statements correctly declares a variable named Cof the data type MatrixType? A) MatrixTypel MAXROWSUIMAXCOLSU C; B) Matrix Type C, C) int Matrix Type D) None of These 14. Given the global type declaration Matrix Type as described in problem 13, which of the following would be a suitable function prototype for a function named PrintMatrix A) void PrintMatrix( Matrix Typel Jl J); B) void PrintMatrix MatrixType M); C) void PrintMatrix( MatrixType MIMAXROWSJID; D) None of These 15. The void function named GetNums has two parameters A pass-by-value parameter named x of type float A pass-by-value parameter named num of type int Which of the following choices are correct function prototypes for the description of the parameters for the function GetNums? A) void GetNums(float&, int&), B) void GetNums( float& x, int& num); C) void GetNums(float, int num); D) void GetNums(float, int E) none of the above

Explanation / Answer

Solution:

10. The answer is option A) void InitToZero( const int beta)

here, call to the function InitToZero(alpha) send the address of the first subscript of the array int alpha i.e. address of alpha[0]

In function definition as a formal parameter , we say const when the parameter is pointer, and the name of the array without any subcript specification is considered as pointer to the first subscript i.e.&alpha[0].

11. The answer is option A) void InitToZero(const int [20]). Function prototype tells the compiler about the return type, function name, number of arguments of the function and also the data type of each argument. We don't need to give the variable names.

12.The answer is the option B) if(intptr1 == intptr2). we use == operaor to compare the two values fr equality. Here the pointer variables intptr1 and intptr2 stores the address of the integer variables it is pointing. if we put the * before pointer variable it indicates the value of the variable it is pointing at . e.g. *intptr1 means the value stored at the address intptr1.

13.The answer if option B) MatrixType C, since you have used the typedef for the two dimensional array, there no need to specify the subscript again for C. C will be considered as a two dimensional array.

14. The answer is option C)void PrintMatrix(MatrixType[][]); Since we only need to specify the datatype i.e. MatrixType ,which is a two dimensional array.

15. The answer is option D) void GetNums(float,int), as explained in earlier answers, in prototype description we only need to specify the return type, and the number of parameters and the data type of each parameter.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote