Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. Short questions (a) For each of the questions that follow, choose the most appropriate option. i. Which one of the following is a
4. Short questions (a) For each of the questions that follow, choose the most appropriate option. i. Which one of the following is a correct function header for a function that computes and returns the square root of a float value? A. void squareRoot( float value) B. float squareRoot(int value) C. int squareRoot( float value) D. float squareRoot( float value) ii. Which of the following statements about arrays are true? (1) An array may contain elements of different data types. (2) A constant array must have an initialisation list. (3) When an array is passed as an argument to a function, the function has access to the original array. A. (1), (2) and (3) are true. B. (2) and (3) are true. C. (1) and (2) are true. D. Only (3) is true. iii. Given the following array declaration: const int SIZE = 5; int numbers[SIZE] = 10, 15, 20, 25, 30; Which of the following statements will display all the values in the array? A. for (int index= 1; index v. Given the following declarations: float num1 10.5, num2 = 5.2, temp; Which of the following statements will correctly swap the values of num1 and num2; A. B. C. D. num1 num2; num2 numl; num2 = num1; num1 num2; temp = numl; numl num2; num2 temp; temp = num2; num2 temp; num1 = num2; Page 3 vi. Study the program statements below and answer the question that follows. int num= 125; int *numPtr; numPtr&um; cout < < numPtr < < '\t < < *numPtr; What will be displayed on the screen? A. memory address of variable numPtr, followed by a tab, followed by 125 B. memory address of variable num, followed by a tab, followed by 125 C. value of num in hexadecimal followed by a tab followed by 125 D. memory address of variable numPtr followed by a tab followed by NULL vii. Given the following statements: const int SIZE = 5; int values [SIZE] = { 10, 20, 30, 40, 50 }; for (index = 0; index < SIZE; index++) cout < < values [index] < < '\t'; Which of the following cout statements will produce the same output as the cout statement above? A. cout < < *(values + index) B. cout < < &(values + index) < < < '\t'; C. cout < < *values [index] D. cout < < &values [index] < < < '\t'; viii. Given the following statements: const int SIZE = 10; float sarray Ptr = new float [SIZE]; for (int index = 0; index < SIZE; index++) *(array Ptr + index) = index 10.0; //store value in array Which of the following is equivalent to the statement with the comment "store value in array"? A. arrayPtr[index] = index 10.0; B. &array Ptr [index] C. sarray Ptr [index] D. array Ptr + index Page 4 =index 10.0; = index 10.0; index 10.0; (b) What is the reason for undefined behaviour/errors that will occur when the following functions are called. multiply (int n) i. int { } ii. void { int Value n = 3; int q = &Value; ii. int int return q; (2 marks) set ToZero (int * const dptr) dptr = 0; } (c) Indicate if the following overloaded functions are valid or invalid. i. int get Minimum Value (int, int); int get Minimum Value (int, int, int); get Minimum Value (int, int); get Minimum Value (double, int); iii. int get Minimum Value (int, int); void get MinimumValue (int&, int&); (2) (2) (3)
Step by Step Solution
★★★★★
3.49 Rating (172 Votes )
There are 3 Steps involved in it
Step: 1
i D float squareRoot float value Rationale It is the correct function header for a function that com...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started