C++ PROGRAMMING:FROM...(LL) >CUSTOM<
C++ PROGRAMMING:FROM...(LL) >CUSTOM<
8th Edition
ISBN: 9780357019528
Author: Malik
Publisher: CENGAGE C
bartleby

Videos

Textbook Question
Book Icon
Chapter 8, Problem 1TF

Mark the following statements as true or false.

  1. A double type is an example of a simple data type. (1)

  2. A one-dimensional array is an example of a structured data type. (1)

  3. The size of an array is determined at compile time. (1,6)

  4. Given the declaration:

    int list[10];

    the statement:

    list[5] - list[3] * list[2];

    updates the content of the fifth component of the array list. (2)

  5. If an array index goes out of bounds, the program always terminates in an error. (3)

  6. The only aggregate operations allowable on int arrays are the increment and decrement operations. (5)

  7. Arrays can be passed as parameters to a function either by value or by reference. (6)

  8. A function can return a value of type array. (6)

  9. In C++, some aggregate operations are allowed for strings. (11,12,13)

  10. The declaration:

    char name [16] = "John K. Miller";

    declares name to be an array of 15 characters because the string "John K. Miller" has only 14 characters. (11)

  11. The declaration:

    char str = "Sunny Day";

    declares str to be a string of an unspecified length. (11)

    As parameters, two-dimensional arrays are passed either by value or by reference. (15,16)

a.

A double type is a simple data type. Hence, the given statement is “True”.

Expert Solution
Check Mark
Program Plan Intro

A data type is called simple if variables of that type can store only one valueat a time. In contrast, in a structured data type, each data item is a collection of otherdata items. Simple data types are building blocks of structured data types.

Program Description Answer

A double type is a simple data type. Hence, the given statement is “True”.

Explanation of Solution

Since a double type can store a single value at a time it is a simple data type.

b.

One-dimensional array is an example of a structured data type. Hence, the given statement is “True”.

Expert Solution
Check Mark
Program Plan Intro

A data type is called simple if variables of that type can store only one valueat a time. In contrast, in a structured data type, each data item is a collection of otherdata items. Simple data types are building blocks of structured data types.

Program Description Answer

One-dimensional array is an example of a structured data type. Hence, the given statement is “True”.

Explanation of Solution

One-dimensional array is an example of a structured data type, as it can store a collection of other data items.

c.

The size of an array is determined at compile time. Hence, the given statement is “True”.

Expert Solution
Check Mark
Program Plan Intro

An array is a collection of a fixed number of components (also called elements)all of the same data type and in contiguous (that is, adjacent) memory space.

Program Description Answer

The size of an array is determined at compile time. Hence, the given statement is “True”.

Explanation of Solution

An array is a collection of a fixed number of components hence the size of an array is determined at compile time.

d.

The statement does not update the fifth component. Hence, the given statement is “False”.

Expert Solution
Check Mark
Program Plan Intro

In C++[ ] is an operator called the array subscripting operator and the array index starts at 0.

Program Description Answer

The statement does not update the fifth component. Hence, the given statement is “False”.

Explanation of Solution

The statement updates the sixth component of the array list as the subscript begins with 0.

e.

If an array index goes out of bounds, the program does not necessarily terminatein an error. Hence, the given statement is “False”.

Expert Solution
Check Mark
Program Plan Intro

C++ does not check whether the index value is within range. If the index goes out of bounds and the program tries toaccess the component specified by the index, then whatever memory location is indicatedby the index that location is accessed. This can result in altering or accessingthe data of a memory location that was never intended to be modified or accessed. It can also lead to accessing a protected memory that causes the program to instantly halt. Hence, several unknown things can happen if the index goes out of bounds during execution.

Program Description Answer

If an array index goes out of bounds, the program does not necessarily terminatein an error. Hence, the given statement is “False”.

Explanation of Solution

If the index goes out of bounds and the program tries to access the component specified by the index, then whatever memory location is indicated by the index that location is accessed. This may or may not cause the program to instantly halt or terminate in an error.

f.

C++ does not allow aggregateoperations on an array. Hence, the given statement is “False”.

Expert Solution
Check Mark
Program Plan Intro

An aggregate operation on an array is any operation thatmanipulates the entire array as a single unit.

Program Description Answer

C++ does not allow aggregateoperations on an array. Hence, the given statement is “False”.

Explanation of Solution

C++ does not allow aggregate operations on an array.

g.

Arrays can be passed as parameters to a function never by value but only by reference. Hence, the given statement is “False”.

Expert Solution
Check Mark
Program Plan Intro

In C++, arrays are passed by reference only. Because arrays are passed by reference only, the &symbol is never used when declaringan array as a formal parameter.

Program Description Answer

Arrays can be passed as parameters to a function never by value but only by reference. Hence, the given statement is “False”.

Explanation of Solution

In C++, arrays are passed by reference only and never by value.

h.

A function cannot return a value of type array. Hence, the given statement is “False”.

Expert Solution
Check Mark
Program Plan Intro

A function cannot return a value of type array.

Program Description Answer

A function cannot return a value of type array. Hence, the given statement is “False”.

Explanation of Solution

A function cannot return a value of type array.

i.

In C++, some aggregate operations are allowed for strings. Hence, the given statement is “True”.

Expert Solution
Check Mark
Program Plan Intro

Most rules that apply to arrays apply to C-strings as well. Aggregateoperations, such as assignment and comparison, are not allowed on arrays. Also the input/output of arrays is done component-wise. But, C++ allows aggregate operations of the input and output on C-strings which are nothing but character arrays terminated with the null character.

Program Description Answer

In C++, some aggregate operations are allowed for strings. Hence, the given statement is “True”.

Explanation of Solution

C++ allows aggregate operations of the input and output on C-strings which are nothing but character arrays.

j.

The name array is of size 16 and not 15. Hence, the given statement is “False”.

Expert Solution
Check Mark
Program Plan Intro

The name array is of size 16 which is mentioned in the declaration of the variable and not the size of string stored into it. There remains 1 unused component in the name array.

Program Description Answer

The name array is of size 16 and not 15. Hence, the given statement is “False”.

Explanation of Solution

The name array is of size 16 which is mentioned in the declaration of the variable and not the size of string stored into it. There remains 1 unused component in the name array.

k.

Aggregate operation such as assignment is not allowed on arrays and the statement is illegal. Hence, the given statement is “False”.

Expert Solution
Check Mark
Program Plan Intro

Aggregate operation such as assignment is not allowed on arrays and the statement is illegal. For assignment operation on c-strings (char arrays) c-string functions are needed.

Program Description Answer

Aggregate operation such as assignment is not allowed on arrays and the statement is illegal. Hence, the given statement is “False”.

Explanation of Solution

Aggregate operation such as assignment is not allowed on arrays and the statement is illegal. For assignment operation on c-strings (char arrays) c-string functions are needed.

l.

Two-dimensional arrays can be passed as parameters to a function, and they arepassed by reference only. Hence, the given statement is “False”.

Expert Solution
Check Mark
Program Plan Intro

Two-dimensional arrays can be passed as parameters to a function, and they arepassed by reference.

Program Description Answer

Two-dimensional arrays can be passed as parameters to a function, and they arepassed by reference only. Hence, the given statement is “False”.

Explanation of Solution

Two-dimensional arrays can be passed as parameters to a function, and they arepassed by reference.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
In C programming: Write a main() function using the following requirements:• Define a SIZE constant (the value is irrelevant, but for testing, you may want to keep it small enough – no bigger than 5)• Create an array of course pointers using SIZE• Dynamically allocate each element of the array• Call inputAllCourses()• Call printAllCourses().
void mystery2(int list[], int length) { for (int i = 0; i < length - 1; i++) { if (i % 2 == 0) { list[i]++; } else { list[i]--; } }}   For each array below, indicate what the array's contents would be after the function were called and passed that array as its parameter. use the following as input.   {6, 3}   {2, 4, 6}   {1, 2, 3, 4}   {2, 2, 2, 2, 2}   {7, 3, 2, 0, 5, 1}
JAVA LANGUAGE
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License