COP1220 Final Exam Questions With Verified And Updated Solutions.
COP1220 Final Exam Questions With Verified And Updated Solutions. Given two integer arrays, largerArray with 4 elements, and smallerArray with 3 elements. What is the result after this code executes? for (i = 0; i 4; ++i) { largerArray[i] = smallerArray[i]; } a.All the elements of largerArray will get copied to smallerArray. b.Some of the elements of largerArray will get copied to smallerArray. c.All of the elements of smallerArray will get copied to largerArray. d.Error: The two arrays are not the same size. - answerD What line of code assigns a char variable outputGames with the value the gamesPointer points to? char userGames = 'B'; char* gamesPointer; tGames = gamesPointer; tGames = *gamesPointer; Char = &gamesPointer; Pointer = outputGames; - answerB What is the output? int MyFct(int x) { int y; x = x * 2; y = x + 1; return y; } int main(void) { int a; a = 5; printf("%d %d", a, MyFct(a)); return 0; } a.5 6 b.5 11 c.6 11 d.Error: Cannot assign parameter x - answerB Which XXX / YYY declare an array having MAX_SIZE elements and initializes all elements with -1? const int MAX_SIZE = 4; int myNumbers[XXX]; int i; for (i = 0; i YYY; ++i) { myNumbers[i] = -1; } a.MAX_SIZE / MAX_SIZE b.MAX_SIZE / MAX_SIZE - 1 c.MAX_SIZE - 1 / MAX_SIZE d.MAX_SIZE - 1 / MAX_SIZE - 1 - answerA A function defined beginning with void SetNegativesToZeros(int userValues[], ... should modify userValues such that any negative integers are replaced by zeros. The function _____. d make a local copy of the array and then set the copy's negative values to zeros t be written because an array passed to a function is constant so cannot be modified modify the array's elements directly because arrays are passed by pointer d define userValues as const int& userValues to be able to modify the array's elements - answerC For the following function, which is a valid function call? Assume maxValue is an integer. int Max(int x, int y) { if (x y){ return x; } else { return y; } } Value = Max(15 25); Value = Max(); Value = Max(15, Max(35, 25)); d.Max = maxValue(15, 25); - answerC The following program generates an error. Why? const int NUM_ELEMENTS = 5; int userVals[NUM_ELEMENTS]; unsigned int i; userVals[0] = 1; userVals[1] = 7; userVals[2] = 4; for (i = 0; i = NUM_ELEMENTS; ++i) {
Written for
- Institution
- COP1220
- Course
- COP1220
Document information
- Uploaded on
- June 25, 2024
- Number of pages
- 41
- Written in
- 2023/2024
- Type
- Exam (elaborations)
- Contains
- Questions & answers
Subjects
-
cop1220 final exam questions with verified and upd