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

Question 5 What does the following program do? Question 5 options: It prints 1 2

ID: 2079934 • Letter: Q

Question

Question 5

What does the following program do?

Question 5 options:

It prints 1 2 3 4.

The program incurs a segmentation fault when run.

It does not compile. You cannot copy arrays like that.

It does not compile. You cannot print an entire array like that.

question 6

Arrays are just pointers in disguise.

Question 6 options:

Question 7

Declaring too large an array in a function may cause a stack overflow when the function is called.

Question 7 options:

Question 8

What does the following program do?

Question 8 options:

It crashes because main can only return 0.

It returns 3.

It returns 4.

It does not compile.

Question 9

What does the following program do?

Question 9 options:

It does not compile.

It prints: 1 1 1 1 1

Prints: 1 2 3 4 5.

It crashes because it causes a segmentation fault.

Question 10

What does the following program do?

Question 10 options:

It crashes because p != a+n accesses an address that isout of bounds.

It doesn't compile. You cannot assign an array to a pointer because they are of different types.

It prints nonsense because %d is for integers, while p is a pointer.

It prints: 0 1 2 3 4

A

It prints 1 2 3 4.

B

The program incurs a segmentation fault when run.

C

It does not compile. You cannot copy arrays like that.

D

It does not compile. You cannot print an entire array like that.

Explanation / Answer

5. We will get a compilation error stating that "incompatible types when assigning to type 'int[4]' from type 'int *'"
6. True
Arrays in C++ are actually just pointers in disguise! When an array is passed to a function, C++ passes a pointer to the rst element of the array. This way, the array does not have to be copied. Because the address is used, the function can change data outside the scope of the function.
7. True.
In this case allocation should be done in heap memory not stack.
8. It does not compile.
error: assigning to an array from an initializer list
a = {1,2,3,4};
9.Prints: 1 2 3 4 5.
10.It prints: 0 1 2 3 4

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