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

For each of the following items, cirele all the true statements. In cach item, z

ID: 3919952 • Letter: F

Question

For each of the following items, cirele all the true statements. In cach item, zero, one, or more than one statement might be true. (a) Let a [100] be an array of ints, n an int giving the size of a (namely 100), and void 8int at), int n) a function that multiplies each element in a by a factor of 10. Assume a has already been declared and initialized. Circle all the statements below that are true about the values in the array before and after the function call g(a, 100) The values of a after the function call will be the same as before the function call The values of a after the function call will be the same as before the function call but they would differ f the function g was rewritten with a reference symbol (&) s void g(int& a], int n) The values of a after the function call will differ from those before the funetion call (b) An aquatic meet often consists of swimming events and diving events, with swimming events sorted into one of 6 types: freestyle, back stroke, butterfly, breaststroke, medley, or relay. If you wrote a program that included the following classes: Freestyle, BackStroke Butterfly, Breast Stroke, Medley, Relay, SwimEvent, DiveEvent, and AquaticMeet, what would be the likely relationships among those classes? Circle all of the following that are likely to be true. . The Medley class would have access to protected variables from the AquaticMeet class. .The Butterfly class would be a child class of the SwimEvent parent class The AquaticMeet class would be a child class of the SwimEvent parent class The AquaticMoet class would have a member variable that is an array of SwimEvent objects (c) Circle all the statements below that are true about the C++ declaration double *1, m; . &1 is undefined ·C++ does not allow this type of statement (it produces a compiler error). 1 is a pointer to a double, and it is equal to &m.; 1 is a pointer to a double, and m is a double

Explanation / Answer

(a)

int a[100];
int n=100;
g(int a[],int n)
{
for(int i=0;i<n;i++)
{
a[i]*=10;
}
}

Here since a is an integer array, the array is sent as a pointer (the value is passed by reference) to the function, thus if the value of a is changed in the function, it is reflected in the original value of a.

Thus the first two option in the (a) is wrong because they imply that after the function call the value will be the same as before.

Only option 3 is correct because the value will differ before and after the function call as it is passed by reference.

(b)

Since the swim event is sorted into 6 types, the 6 types (freestyle, backstroke, butterfly, breaststroke, relay, medley) would be derived from the swim event, that is the swimEvents is the parent class of these classes and in the class aquaticMeet will have an object of either of the one of the swimEvents derived class.

The first option is FALSE because the Medley class is derived from the swimEvents class and is a child class of the swimEvents class. Thus it will NOT have ACCESS to the protected variables of the aquaticMeet class.

The second option is TRUE because the butterfly class is derived from the swimEvents class and is a child class of the swimEvents class.

The aquatic meet is not the child class of the swimEvents class thus the third point is WRONG.

The last option is also WRONG because the aquaticMeet class would have an object of the swimevents derived class and not the swimEvents class itself.

(c)

double *l,m;

this statement declares a pointer to a double which is l and a normal double which is m. It does not assign any value to the pointer or the double.

&l is undefined is TRUE because the reference can be considered as a constant pointer which holds the address of a particular variable and it should be assigned when it is declared.

No error is produced while using this statement in C++ as a pointer can be reassigned to any variable depending on its use. Thus the second point is WRONG.

The pointer is not assigned any value in the case of the statement and thus the third point is also WRONG. The pointer and the double variables are only initialized.

The last point or the fourth point is TRUE because they are just created as it is. l is a pointer and m is a double.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote