C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
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
A dequeue is a list from which elements can be inserted or deleted at either end a. Develop an array based implementation for dequeue. b. Develop a pointer based implementation dequeue.
Part 1: Array list implementation: array list implements list interface plus their own functions. 1. a. Create a ArrayList of type Integer and name it as Grades. b. Create a ArrayList of type String and name it as Students. c. Create a ArrayList of type Double and name it as Results. 2. Add the following values to the array List using add function 30, 40,80 ,100,70,100,10,100,10 Print the size of the array list using size () function. 3.Search for 100 in the array list, if you find it, print a message that “those grades are perfect”. Use only contains function. 4. Repeat the step 3 using equals function. 5. Check if array list is empty or not using isEmpty() function. Print a message if it’s empty and if it’s not empty also. 6. the grade is under 20 which is outlier, remove it from the array list. 7. Print array list using System.out.println() 8. Use indexOf to print index of 80. 9. Use get function. 10. What is the difference between get and index of? 11. Print the values of the array…
Array Challenge 4. Write a program in C# to copy the elements of one array into another array.Test Data :Input the number of elements to be stored in the array :3Input 3 elements in the array :element - 0 : 15element - 1 : 10element - 2 : 12Expected Output :The elements stored in the first array are :15 10 12The elements copied into the second array are :15 10 12
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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
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