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

As long as the types are the same, one array can be copied to another using assi

ID: 3854785 • Letter: A

Question

As long as the types are the same, one array can be copied to another using assignment operator. To declare an array as an array as a variable-length array. we can use an asterisk for the array size. In each pass of the insertion sort, the smallest element in the unsorted sublist is transferred into the sorted sublist by inserting it at the appropriate place. By convention, in a two-dimensional array, the first dimension specifies the number of columns and the second specifies the number of rows. Which of the following statements about array declaration is false? a. The array size is optional. b. The array type must be specified. c. Arrays may be initialized when they are declared. d. Array declarations may indicate fixed or variable sized arrays e. Once an array size is declared, it cannot be changed. Which of the following statements about arrays is true? a. The number of elements in a fixed-size array is determined when the program is executing. b. To process all of the elements in an array, a for-loop is typically used c. An arrays name is a symbolic reference for the address to the last byte of the array d. An index of 5 represents an offset of 5 bytes in an array of integers. e. C uses an index value enclosed between { and } to access individual elements in an array. Like an array all f the elements in a structure must be of the same type.

Explanation / Answer

Solution:

8. Answer is False.

Explanation:

We cannot use assignment opeartor to copy one array to another array, even if the type is same.

But we can use pointer to do so.

For example: char A[] = "Hi";

char* B = A; // Pointer assignment, allowed

9. The answer is False.

Explanation:

We cannot use asterisk, to define the size of a variable length array.

Instead, we can use the variable to define the size of an array.

for example,

int n;

char A[n];

10. The answer is True.

Explanation:

Insertion sort is an iterative method of sorting the unsorted list.

It reads the one element at a time from the unsorted list and inserts that element at appropriate position in the sorted list, by growing the list.

Insertion sort is simple to implement, but is not very effective on large lists.

11. The answer is False.

Explanation:

When we declare two dimentional array, the first subscript specifies the number of rows and the second subscript specifies the number of columns.

For example:

int A[3][2];

Here, A is two dimentional array with 3 rows and two columns.

12. The answer is

a. The array size is optional.

Explanation:

The array size is not optional.

To declare an array, we must specify:

a. Type

b. Identifier(name of an array)

c. size

For example:

int A[5];

Here int is the type of the array

A is array name

[5] is the size of array A.

13. The answer is

b. To process all of the elements in an array, a for loop is typically used.

Explanation:

Since array size is fixed, a for loop is used typically to process all the elements in an array.

For example:

int A[5];

for(int i=0; i < 5; i++)

A[i] = i;

Here, we access all the indices of array A, using for loop.

After the execution of for loop, A will have following elements:

A = {0,1,2,3,4}

14. The answer is False.

Explanation:

Structure is a data structure, which is a group of heterogenous elements.

For example:

strcut student

{

int Roll_no;

char Name[10];

};

Here, the structure student has two members Roll_no of type integer and Name of type string(array of characters)