Mark the following statements as true or false.
A double type is an example of a simple data type. (1)
A one-dimensional array is an example of a structured data type. (1)
The size of an array is determined at compile time. (1,6)
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)
If an array index goes out of bounds, the
program always terminates in an error. (3)The only aggregate operations allowable on int arrays are the increment and decrement operations. (5)
Arrays can be passed as parameters to a function either by value or by reference. (6)
A function can return a value of type array. (6)
In C++, some aggregate operations are allowed for strings. (11,12,13)
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)
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”.
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.
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”.
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.
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”.
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.
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”.
In C++[ ] is an operator called the array subscripting operator and the array index starts at 0.
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”.
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.
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”.
An aggregate operation on an array is any operation thatmanipulates the entire array as a single unit.
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”.
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.
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”.
A function cannot return a value of type array.
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”.
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.
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”.
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.
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”.
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.
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”.
Two-dimensional arrays can be passed as parameters to a function, and they arepassed by reference.
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?
Chapter 8 Solutions
C++ Programming: From Problem Analysis to Program Design
- 1. Complete the routing table for R2 as per the table shown below when implementing RIP routing Protocol? (14 marks) 195.2.4.0 130.10.0.0 195.2.4.1 m1 130.10.0.2 mo R2 R3 130.10.0.1 195.2.5.1 195.2.5.0 195.2.5.2 195.2.6.1 195.2.6.0 m2 130.11.0.0 130.11.0.2 205.5.5.0 205.5.5.1 R4 130.11.0.1 205.5.6.1 205.5.6.0arrow_forwardAnalyze the charts and introduce each charts by describing each. Identify the patterns in the given data. And determine how are the data points are related. Refer to the raw data (table):arrow_forward3A) Generate a hash table for the following values: 11, 9, 6, 28, 19, 46, 34, 14. Assume the table size is 9 and the primary hash function is h(k) = k % 9. i) Hash table using quadratic probing ii) Hash table with a secondary hash function of h2(k) = 7- (k%7) 3B) Demonstrate with a suitable example, any three possible ways to remove the keys and yet maintaining the properties of a B-Tree. 3C) Differentiate between Greedy and Dynamic Programming.arrow_forward
- What are the charts (with their title name) that could be use to illustrate the data? Please give picture examples.arrow_forwardA design for a synchronous divide-by-six Gray counter isrequired which meets the following specification.The system has 2 inputs, PAUSE and SKIP:• While PAUSE and SKIP are not asserted (logic 0), thecounter continually loops through the Gray coded binarysequence {0002, 0012, 0112, 0102, 1102, 1112}.• If PAUSE is asserted (logic 1) when the counter is onnumber 0102, it stays here until it becomes unasserted (atwhich point it continues counting as before).• While SKIP is asserted (logic 1), the counter misses outodd numbers, i.e. it loops through the sequence {0002,0112, 1102}.The system has 4 outputs, BIT3, BIT2, BIT1, and WAITING:• BIT3, BIT2, and BIT1 are unconditional outputsrepresenting the current number, where BIT3 is the mostsignificant-bit and BIT1 is the least-significant-bit.• An active-high conditional output WAITING should beasserted (logic 1) whenever the counter is paused at 0102.(a) Draw an ASM chart for a synchronous system to providethe functionality described above.(b)…arrow_forwardS A B D FL I C J E G H T K L Figure 1: Search tree 1. Uninformed search algorithms (6 points) Based on the search tree in Figure 1, provide the trace to find a path from the start node S to a goal node T for the following three uninformed search algorithms. When a node has multiple successors, use the left-to-right convention. a. Depth first search (2 points) b. Breadth first search (2 points) c. Iterative deepening search (2 points)arrow_forward
- We want to get an idea of how many tickets we have and what our issues are. Print the ticket ID number, ticket description, ticket priority, ticket status, and, if the information is available, employee first name assigned to it for our records. Include all tickets regardless of whether they have been assigned to an employee or not. Sort it alphabetically by ticket status, and then numerically by ticket ID, with the lower ticket IDs on top.arrow_forwardFigure 1 shows an ASM chart representing the operation of a controller. Stateassignments for each state are indicated in square brackets for [Q1, Q0].Using the ASM design technique:(a) Produce a State Transition Table from the ASM Chart in Figure 1.(b) Extract minimised Boolean expressions from your state transition tablefor Q1, Q0, DISPATCH and REJECT. Show all your working.(c) Implement your design using AND/OR/NOT logic gates and risingedgetriggered D-type Flip Flops. Your answer should include a circuitschematic.arrow_forwardA controller is required for a home security alarm, providing the followingfunctionality. The alarm does nothing while it is disarmed (‘switched off’). It canbe armed (‘switched on’) by entering a PIN on the keypad. Whenever thealarm is armed, it can be disarmed by entering the PIN on the keypad.If motion is detected while the alarm is armed, the siren should sound AND asingle SMS message sent to the police to notify them. Further motion shouldnot result in more messages being sent. If the siren is sounding, it can only bedisarmed by entering the PIN on the keypad. Once the alarm is disarmed, asingle SMS should be sent to the police to notify them.Two (active-high) input signals are provided to the controller:MOTION: Asserted while motion is detected inside the home.PIN: Asserted for a single clock cycle whenever the PIN has beencorrectly entered on the keypad.The controller must provide two (active-high) outputs:SIREN: The siren sounds while this output is asserted.POLICE: One SMS…arrow_forward
- 4G+ Vo) % 1.1. LTE1 : Q B NIS شوز طبي ۱:۱۷ کا A X حاز هذا على إعجاب Mohamed Bashar. MEDICAL SHOE شوز طبي ممول . اقوى عرض بالعراق بلاش سعر القطعة ١٥ الف سعر القطعتين ٢٥ الف سعر 3 قطع ٣٥ الف القياسات : 40-41-42-43-44- افحص وكدر ثم ادفع خدمة التوصيل 5 الف لكافة محافظات العراق ופרסם BNI SH ופרסם DON JU WORLD DON JU MORISO DON JU إرسال رسالة III Messenger التواصل مع شوز طبي تعليق باسم اواب حمیدarrow_forwardA manipulator is identified by the following table of parameters and variables:a. Obtain the transformation matrices between adjacent coordinate frames and calculate the global transformation matrix.arrow_forwardWhich tool takes the 2 provided input datasets and produces the following output dataset? Input 1: Record First Last Output: 1 Enzo Cordova Record 2 Maggie Freelund Input 2: Record Frist Last MI ? First 1 Enzo Last MI Cordova [Null] 2 Maggie Freelund [Null] 3 Jason Wayans T. 4 Ruby Landry [Null] 1 Jason Wayans T. 5 Devonn Unger [Null] 2 Ruby Landry [Null] 6 Bradley Freelund [Null] 3 Devonn Unger [Null] 4 Bradley Freelund [Null] OA. Append Fields O B. Union OC. Join OD. Find Replace Clear selectionarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT