EBK C++ PROGRAMMING: PROGRAM DESIGN INC
EBK C++ PROGRAMMING: PROGRAM DESIGN INC
8th Edition
ISBN: 9781337669085
Author: Malik
Publisher: VST
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
Java Programming : A party has been organised on cruise. The party is organised for a limited time (T). The number of guests entering (E[i]) and leaving (L[i]) the party at every hour is represented as elements of the array. The task is to find the maximum number of guests present on the cruise at any given instance within T hours. Example 1: Input : 5 > Value of T [7,0,5,1,3] -> E[], Element of E[0] to E[N-1], where input each element is separated by new line [1,2,1,3,4] -> L[], Element of L[0] to L[N-1], while input each element is separate by new line. Output : 8 -> Maximum number of guests on cruise at an instance. Explanation: 1st hour: Entry 7 Exit: 1 No. of guests on ship : 6 2nd hour : Entry Exit : 2 No. of guests on ship: 6-2=4 Hour 3: Entry: 5 Exit: 1 No. of guests on ship : 4+5-1-8 Hour 4: Entry 1 Exit 3 No. of guests on ship: 8+1-3=6 Hour 5: Entry 3 Exit: 4 No. of guests on ship: 6+3-4-5 Hence, the maximum number of guests within 5 hours is 8.
TRUE OR FALSE   1. One disadvantage of Boolean type is readability 2. When string length is specified at the declaration time then we call it Static Length   3. In stack-dynamic array subscript ranges are dynamically bound 4. Access to record elements is slower than access to array 5. It is possible to check type (type checking) when using free union
Write in Java. initializer list example: int [] array = {1,2,3};
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