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

Consider the code at the right, and answer the following three (3) questions. If

ID: 3807778 • Letter: C

Question

Consider the code at the right, and answer the following three (3) questions. If the data file contains 21 unique double values, which ONE of the following statements best describes what will happen? a. Double values will be stored beyond the bounds of the array, leading to undefined behavior. b. The while loop will terminate as soon as 16 values have been read from the file and stored into the array. c. Nothing will be stored into any element of the array. d. The fscanf function will fail as soon as 16 values have been read from the file. e. When we compile the source code, the compiler will issue an error indicating that we are storing beyond the bounds of the array. Assuming that the data file contains only four values 42.2, 1977.7, 7734.40, and 3.14159, in that order, which ONE of the following statements is FALSE? a. my Data [0] will contain the value 42.2. b. my Data [3] will contain the value 3.14159. c. my Data [4] will contain the value 3.14159. d. myData[5] will contain the value 0. e. myData [15] will contain the value 0. f. my Data [2] will contain the value 7734.40. If the data file contains between 5 and 16 values, which ONE of the following statements is FALSE? a. Any array elements that are not populated inside the while loop will contain the value 0. b. The value of variable i will contain the number of values successfully stored into the array. c. The next call to fscanf, after reading the last value from the file, will return a value other than 1. d. Nothing will be stored by the while loop into any element of the array. In a function definition ProcessArray that is designed to receive as an argument the address of the beginning of a two-dimensional array of doubles, with 7 rows and 5 columns, and we need to use array notation inside the function to access array elements, which of the following function prototypes are acceptable to the compiler? Select ALL correct responses. a. void ProcessArray(double arr [7][5], int rows, int cols); b. void ProcessArray(double arr [][5], int rows, int cols); c. void ProcessArray(double arr [7][], int rows, int cols); d. void ProcessArray(double arr [] [], int rows, int cols); e. void ProcessArray(double arr, int rows, int cols); double myData (16) = (0); int i = 0; FILE * fp; fp = f open (*c:\data\file2.txt", "r"); if (fp ! = NULL)// if f open succeeded { double val; while (fscan f(fp, "if", &val;) --1 { myData [i] = val; i++; } fclose(fp); }

Explanation / Answer

4. e when we compile, the compiler will issues an error.

5. c data[4]=3.14159 is false because array index starts from 0.

6. d Nothing will be strored is false. (whatever number of elements in interval 5 to 16 will be stored)

7. a , b