Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
COP 3223 Section 1 Spring 2017 Exam 2 Review Full Disclosure: I am not the professor, and I am not making your real exam. This test is strictly for practice. This test may cover more, or even less than what is on the actual test. This test is my best guess of what would be important to study. A student with questions about the content of the actual exam should consult either the TAs or the professor Once an array is made, you cannot change the size. a. True b. False To close a file, you simply set the file pointer equal to NULL. a. True b. False If you select an output file that doesn't exist, what happens? a. A compilation error occurs b. The file pointer is null c. The file pointer is not null, but a runtime error occurs d. The file will be created, with the content you wrote to the file pointer To traverse a two dimensional integer array, the best choice is most likely a. A single for loop b. Multiple for loops c. A single while loop d. Multiple while loops Each value in a character array is initialized to a. The null terminator, ‘\0' b. An empty character, ‘' c. The space character, d. They are not initialized Which of these properly declares an array of size 10? a. int arr [10]; b. int arr [11]; c. array int arr [10]; d. array int arr [11]; Which of the following does NOT declare a file pointer? a. FILE * ifp = fopen(“input.txt”, “r”); b. FILE * file; c. fopen(ofp, “output.txt”, “w”); d. FILE * ofp; sum = 0; for(i=1; i<30; i*=3) sum += i; printf("%d", sum); What is the output of the above code? a. 4 b. 27 c. 40 d. 81 e. None of the above sum = 0; for(i =0; i<25; i++) { for(j=0; j<5; j++) sum++; } printf("%d", sum); What is the output of the above code? a. 25 b. 30 c. 50 d. 125 e. None of the above int var[6] = {1,2,3,4,5,6} int i, j, sum = 0; for(j=0; j<5; j++) { for(i=5; i>0; i--) { sum += var[i]; var[i] = var[i-1]; } sum+=var[i] } for(i=0; i<6; i++) printf("%d", var[i]); What is the output of the above code? #include <stdio.h> int main() { int vals[] = {4, 6, 7, 2, 1, 5, 3, 0}; int array[8]; int i; for (i=0; i<8; i++) array[vals[i]] = i; printf("%d %d\n", array[0], array[1]); printf("%d %d\n", array[2], array[3]); printf("%d %d\n", array[4], array[5]); printf("%d %d\n", array[6], array[7]); return 0; } What is the first line of output of the program above? a) 4 6 b) 6 4 c) 4 7 d) 7 4 e) None of the Above What is the second line of output of the program above? a) 7 2 b) 2 7 c) 3 6 d) 6 3 e) None of the Above What is the third line of output of the program above? a) 0 5 b) 5 0 c) 1 5 d) 5 1 e) None of the Above What is the fourth line of output of the program above? a) 2 1 b) 1 2 c) 3 0 d) 0 3 e) None of the Above Write a loop that generates 25 random numbers in between 1-32 and prints each random number. Write a function that takes 4 floats and returns the average of the four. Write a while loop that traverses a 2d integer array and inserts a random integer between 3 - 50 in each cell. int myArray[5][5]; Write a function that has one positive even integer parameter n, and returns the sum of all the positive even integers up to n. ex) the sum 2+4+6+8+ ... +n Write a program to open a file called input.txt read the file until the end of file and increase each number by seven and write it to a new file called output.txt. Input.txt -------------------3 24 11 56 9 37 14 450 21