Question

In: Computer Science

The statement: "int ar[7] = {0};" sets all of the array elements of ar to 0...

The statement: "int ar[7] = {0};" sets all of the array elements of ar to 0 (zero)

True

False

-------------------------------------------

#define SIZE 3 - declares a constant value named SIZE, equal to 3, that is available throughout your program and is immutable.

True

False

----------------------------------------

Select all of the following that apply to an array:

1.

Contiguous storage is storage without any gaps.

2.

Arrays make programming complex problems more difficult.

3.

An arrays elements are stored contiguously in memory.

4.

We can declare an array without defining a size or adding any elements at the time of declaration.

5.

An array is a data structure consisting of an ordered set of elements of common type

We define constants so that when a value that is used frequently throughout a program must be changed, we only have to change the value in one place.

True

False
====================================

Select all of the following answers that are true:

1.

In order to store 30 characters in a C string we must allocate enough space for 31 elements.

2.

The format specifier to print a C string using printf is %c.

3.

The index of the null terminator in a C string represents the number of meaningful characters in the string.

4.

The null terminator has the value 0 (zero) on some host platforms, and the value -1 on others.

Select all of the following statements which are true:

1.

The elements of parallel arrays with the same index make up the fields of a single record of information.

2.

In parallel arrays it is not always the case that the key and the value are stored at the same index.

3.

In a simple set of two parallel arrays, one array holds the key and the other array holds the value.

4.

Parallel arrays are an inconvenient way to store tabular information.

---------------------------

The index of the first element of an array is usually 0 (zero), but can be set to a different value.

True

False

Solutions

Expert Solution

The statement: "int ar[7] = {0};" sets all of the array elements of are to 0 (zero)

True

False

Answer: True

////////////////////////////////////////////////////////////////////////////////

#define SIZE 3 - declares a constant value named SIZE, equal to 3, that is available throughout your program and is immutable.

True

False

Answer: True

////////////////////////////////////////////////////////////////////////////////

Select all of the following that apply to an array:

1.

Contiguous storage is storage without any gaps.

2.

Arrays make programming complex problems more difficult.

3.

An arrays elements are stored contiguously in memory.

4.

We can declare an array without defining a size or adding any elements at the time of declaration.

5.

An array is a data structure consisting of an ordered set of elements of common type

Answer:

1. Contiguous storage is storage without any gaps. False

2. Arrays make programming complex problems more difficult. False

3. An arrays elements are stored contiguously in memory. True

4. We can declare an array without defining a size or adding any elements at the time of declaration. True

5. An array is a data structure consisting of an ordered set of elements of common type True

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

We define constants so that when a value that is used frequently throughout a program must be changed, we only have to change the value in one place.

True

False

Answer:

True

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Select all of the following answers that are true:

1.

In order to store 30 characters in a C string we must allocate enough space for 31 elements.

2.

The format specifier to print a C string using printf is %c.

3.

The index of the null terminator in a C string represents the number of meaningful characters in the string.

4.

The null terminator has the value 0 (zero) on some host platforms, and the value -1 on others.

Answer:

1. In order to store 30 characters in a C string we must allocate enough space for 31 elements. True

2.  The format specifier to print a C string using printf is %c. True

3. The index of the null terminator in a C string represents the number of meaningful characters in the string True

4. The null terminator has the value 0 (zero) on some host platforms, and the value -1 on others. False

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Select all of the following statements which are true:

1.

The elements of parallel arrays with the same index make up the fields of a single record of information.

2.

In parallel arrays it is not always the case that the key and the value are stored at the same index.

3.

In a simple set of two parallel arrays, one array holds the key and the other array holds the value.

4.

Parallel arrays are an inconvenient way to store tabular information.

Answer:

1. The elements of parallel arrays with the same index make up the fields of a single record of information True

2. In parallel arrays it is not always the case that the key and the value are stored at the same index. False

3. n a simple set of two parallel arrays, one array holds the key and the other array holds the value. True

4. Parallel arrays are an inconvenient way to store tabular information. False

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

The index of the first element of an array is usually 0 (zero), but can be set to a different value.

True

False

Answer: True


Related Solutions

A.) myNums is an array of 50 elements of type int and k is an int...
A.) myNums is an array of 50 elements of type int and k is an int variable. For which one we get the index of out of bounds? a. for (k = 0; k <= 49; k++)     cout << myNums[k] << " "; b. for (k = 1; k < 50; k++)     cout << myNums[k] << " "; c. for (k = 0; k <= 50; k++)     cout << myNums[k] << " "; d. for (k =...
// Given an int array of size elements, determine if there are k elements that add...
// Given an int array of size elements, determine if there are k elements that add up to sum. // The array holds integers, both positive and negative and zero. // It is not possible to add zero elements (that's when k==0) to any sum, not even zero. // It is not possible to add any elements from an empty array. // Must be recursive and not iterative //bool K_element_sum(size_t k, int sum, int arr[], size_t size){}
class Arrays1{ public int getSumOfValues(int[] arr){ // return the sum of values of array elements int...
class Arrays1{ public int getSumOfValues(int[] arr){ // return the sum of values of array elements int sum = 0; int i; for(i = 0; i < arr.length; i++){ sum += arr[1]; } return sum; } public int getAverageValueInArray(int[] arr){ // return the average value of array elements int value = 0; for(int i = 0; i < arr.length; i++){ double average = value/ arr.length; } return value; } public int getNumberOfEvens(int[] arr){ //return the number of even values found in...
Given a 2D array a, sum up ALL the edges of the array. Ex. int a[...
Given a 2D array a, sum up ALL the edges of the array. Ex. int a[ ][ ] = { {1, 2, 3, 4},                        {5, 6, 7, 8},                        {9, 10, 11, 12} }; OUTPUT: Sum of the edges = 65
Overlapping Arrays (C++) An array overlaps another array if all elements of the latter array exist...
Overlapping Arrays (C++) An array overlaps another array if all elements of the latter array exist in the former array. They need not necessarily be in the same order. For example, [1,7,3,4,2] overlaps [1,2,3] because 1,2 and 3 exist in [1,7,3,4,2]. To make the implementation easy, [1,7,3,4,2] overlaps [1,1,2,3] as well. We don’t need to check whether 1 appears twice in the first array. Write a program that lets the user enter two arrays and displays whether the first array...
Ceate a two dimensional array of int type to hold scores (on a scale of 0...
Ceate a two dimensional array of int type to hold scores (on a scale of 0 to 100) for 10 students (row) for 3 courses (columns) and initialize the array with your preferred data. All the students get 10 bonus points for course #2 (index 1) . Use for a loop to add the bonus points. c programming language
//2.-------------------------------------------------------------- Given an array of size N, what is the complexity? int m = A[0]; for...
//2.-------------------------------------------------------------- Given an array of size N, what is the complexity? int m = A[0]; for (int i=1; i<N; i++) { if (A[i] > m) m = A[i]; } int k = 0; for (int i=0; i<N; i++) { if (A[i] == m) k++; } What is a (name one) most frequent operation performed?______________________ Expression showing the number of times it is performed ___________ Time Complexity in Big-O Notation O( ) _____________________________________________________ //3.-------------------------------------------------------------- int mult(int N, int M) {   ...
Let A be a collection of sets, then We defined A’ = Union of all elements...
Let A be a collection of sets, then We defined A’ = Union of all elements of A. Definition: If A = NOT the union of C and D , where C and D are non empty sub-collection, such that C’ intersect D’ = empty Then A is coherent. Prove: if A is coherent then A’ is connected (i.e A’ is not the union of two separated sets in standard topology)
The intersection (∩) of two sets (s1, s2) is the set of all elements that are...
The intersection (∩) of two sets (s1, s2) is the set of all elements that are in s1 and are also in s2. Write a function (intersect) that takes two lists as input (you can assume they have no duplicate elements), and returns the intersection of those two sets (as a list) without using the in operator or any built-in functions, except for range() and len(). Write some code to test your function, as well. Note: Do not use the...
C++ Given two finite sets, list all elements in the Cartesian product of these two sets.
C++ Given two finite sets, list all elements in the Cartesian product of these two sets.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT