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

is a collection of statements that performs a specific 5. A task. a constant b.

ID: 3847754 • Letter: I

Question

is a collection of statements that performs a specific 5. A task. a constant b. variable C. array d function e None of these 6. The statements in the body of a while loop may never be execut- ed, whereas the statements in the body of a do-while loop will be executed: a. at least three times b at least twice c. at least once d. never e. None of these 7. Assume you have an array a that is composed of 10 double num- bers, you have a function called getAvg that receives an amay of double numbers and the array size as arguments. The function re- turns the average of these numbers. Which of the following statements shows a comect call for this function? a. double x get Avg(a[10],10). b. double x getAvg(a,10); c. double x getAvg(a[],10); d. double x getAvg (a[10]); e none of the above

Explanation / Answer

5. D(Function):
A function is a group of statements that together perform a task.

6. C(at least once):
In the while loop First the conditon is checked, Which may be false in certain conditions, So the loop may never be executed.
Whereas in the DO-While loop, First the loop is executed, then condition is checked for the repetetion of loop, even if the condition is false the statement is already executed once. So in the DO-While loop, statements in the body is executed atleast once.

7. B(double x= getAvg(a,10)
This is the correct syntax in calling a function to find the average of a function, where a is the array, i is its length.

8. A(Return)
Retrun statement terminates the function immediately,
Break statement terminates the loop immediately,
Exit statement terminates the program immediately.

9. B(is always done by reference)
C++ does not allow to pass an entire array as an argument to a function. However, You can pass a pointer to an array by specifying the array's name without an index.

10. D(int x[2]={2,3,4};)
It will throw an error as too many initializers,
remaining all are valid array definitions.

Please rate it if you get the answer..Thanks...:)