C++PROGRAMING (LL) W/ACCESS
C++PROGRAMING (LL) W/ACCESS
8th Edition
ISBN: 9781337807975
Author: Malik
Publisher: CENGAGE L
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
Write a C++ Program using classes, functions (recursive and otherwise), arrays and other C++ commands that reads words from a file (one column only), storing them into an array.  Once the array is sorted alphabetically ascending, the user is prompted to enter a word.  The program reports whether or not the word was in the array of words. and its position on the array.  If the word is found, the program should report the number of letters in that word.
Write a template function that returns the third minimum out of all the element of an array.The arguments to the function should be the array name and the size of the array (typeint). In main(), exercise the function with arrays of type int, long, double, and char.
C++ programming Recall that in C++, there is no check on an array index out of bounds. However, during program execution, an array index out of bounds can cause serious problems. Also, in C++, the array index starts at 0. Design and implement the class myArray that solves the array index out of bounds problem and also allows the user to begin the array index starting at any integer, positive or negative. Every object of type myArray is an array of type int. During execution, when accessing an array component, if the index is out of bounds, the program must terminate with an appropriate error message. Consider the following statements: myArray list(5);                 //Line1 myArray myList(2, 13);    //Line 2 myArray yourList(-5, 9);   //Line 3 The statement in Line 1 declares list to be an array of five components, the component type is int, and the components are: list[0], list[1], ..., list[4]; The statement in Line 2 declares myList to be an array of 11 components, the component…
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
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