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: 3807135 • 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!

16. Which of the following statements correctly declares a one-dimensional array varable named someArray with exactly 9 elements of type int A) int some Arrayl81, B) int someArrayl9ji C) int someArrayl 101; F) None of these D) typedef int someArrayl9J E) B and D Page 4 of 11 CPE 112 Fall 2016 Exam ill (100 pts November 17, 2016 17.The function PrintMatrix will work only for 2x2 matrices. Assuming that the matrix dimensions are represented by global integer constants MAXROWS and MAXCOLS which specify the maximum number of rows and columns, respectively, in the matrix M, which of the following code fragments would correctly print out the contents of the matrix M row-by-row? If matrix M were as follows: Sample output for matrix M 1 2 3 4 A) int r,c B) int r,c; for (c-0 c MAXCOLS: c++) for (r 0; rk MAXROWS; r++ for (r 0; rKMAXROWS: r++) for (c-0; cek MAXCOLS: c++) cout M[r][c] cout M[r][c] cout end cout end C) int r,cs D) int r,c; for(c 13 c

Explanation / Answer

Answer to Q.16

I am using Java to answer this.

Answer is F none of these.

In Java array is befined as follows:

int someArray[]=new int[9];

You are not allowed to give size during declearing variable. So first three options are invalid.

Also, there is no special keyword called typedef in java.

Q.17

Answer is D.

To understand this first look at the matrix M. We have to print the matrix Row By Row. Obviously, if we have to print matrix row by row the outer for should traverse through rows first as the inner for will give you value of columns in that row. By this way you can print matrix row by row. If you put outer for traversing through columns you will get matraix printed column by column.

So here we have two options left: B and D

To get the answer amongest these two look at the variables r and c. These are initialized with 0. So the condition to achieve the number of rows and column would be r<MAXROWS and c<MAXCOLS

Q.18

Answer is E

To understand this look at the array. It contains exactly 9 elements. So if you are traversing through int initialized with 0 the condition should be k<9 and not k<=9. Secondly ae have to assign value to the element in the array so assignment will be someArray[k]=k;

Thus answer is E

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