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
- Create 2 charts using this data. One without using wind speed and one including max speed in mph. Write a Report and a short report explaining your visualizations and design decisions. Include the following: Lead Story: Identify the key story or insight based on your visualizations. Shaffer’s 4C Framework: Describe how you applied Shaffer’s 4C principles in the design of your charts. External Data Integration: Explain the second data and how you integrated it with the Halloween dataset. Compare the two datasets. Attach screenshots of the two charts (Bar graph or Line graph) The Shaffer 4 C’s of Data Visualization Clear - easily seen; sharply defined• who's the audience? what's the message? clarity more important than aestheticsClean - thorough; complete; unadulterated, labels, axis, gridlines, formatting, right chart type, colorchoice, etc.Concise - brief but comprehensive. not minimalist but not verboseCaptivating - to attract and hold by beauty or excellence does it capture…arrow_forwardHow can I resolve the following issue?arrow_forwardI need help to resolve, thank you.arrow_forward
- Let the user choose encryption or decryption. For encryption, let user input the key in Hexadecimal number, the plain text in Hexadecimal number, output the ciphertext (in hexadecimal numbers). For decryption, let user input the key in Hexadecimal number, the ciphertext (in hexadecimal numbers), output the decrypted message (Hexadecimal number). Both encryption and decryption should output the different operation results for each round like the following: For example: Round 1: E(R0) = ...... (Hex or Binary) K1 = …… E(Ro) xor K1 = S-box outputs = …… f(Ro1, K1) = ….. L2 =R1 =……. La = Ra Round 2: .....• No Encryption/Decryption libraries or functions provided by the third party are allowed. Submit your program codes to Moodle with the notes of how to compile and run your program.arrow_forwardWhen the given integer variable numberOfPackages is: greater than 12, output "Needs more than one box". between 5 inclusive and 12 inclusive, output "Large box". between 0 exclusive and 4 inclusive, output "Small box". less than or equal to 0, output "Invalid input". End with a newline.arrow_forwardsummarize in a short paragraph how to Advance Incident Response and Automation in ML home based security systemsarrow_forward
- 1.[30 pts] Computers generate color pictures on a video screen or liquid crystal display by mixing three different colors of light: red, green, and blue. Imagine a simple scheme, with three different lights, each of which can be turned on or off, projecting onto a glass screen: We can create eight different colors based on the absence (0) or presence (1) of light sources R,G and B: R G B Color 0 0 0 Black 0 0 1 Blue 0 1 0 Green 0 1 1 Cyan 1 0 0 Red 1 0 1 Magenta 1 1 1 0 Yellow 1 White 1 Each of these colors can be represented as a bit vector of length 3, and we can apply Boolean operations to them. a. The complement of a color is formed by turning off the lights that are on and turning on the lights that are off. What would be the complement of each of the eight colors listed above? b. Describe the effect of applying Boolean operations on the following colors: Λ 1. Red(100) ^ Magenta(101)= Blue(001) 2. Bue(001) | Green(010)= 3. Yellow(100) & Cyan(011)= 2.[30 pts] Perform the following…arrow_forwardD. S. Malik, Data Structures Using C++, 2nd Edition, 2010arrow_forwardMethods (Ch6) - Review 1. (The MyRoot method) Below is a manual implementation of the Math.sqrt() method in Java. There are two methods, method #1 which calculates the square root for positive integers, and method #2, which calculates the square root of positive doubles (also works for integers). public class SquareRoot { public static void main(String[] args) { } // implement a loop of your choice here // Method that calculates the square root of integer variables public static double myRoot(int number) { double root; root=number/2; double root old; do { root old root; root (root_old+number/root_old)/2; } while (Math.abs(root_old-root)>1.8E-6); return root; } // Method that calculates the square root of double variables public static double myRoot(double number) { double root; root number/2; double root_old; do { root old root; root (root_old+number/root_old)/2; while (Math.abs (root_old-root)>1.0E-6); return root; } } Program-it-Yourself: In the main method, create a program that…arrow_forward
- I would like to know the main features about the following 3 key concepts:1. Backup Domain Controller (BDC)2. Access Control List (ACL)3. Dynamic Memoryarrow_forwardIn cell C21, enter a formula to calculate the number of miles you expect to drive each month. Divide the value of number of miles (cell A5 from the Data sheet) by the average MPG for the vehicle multiplied by the price of a gallon of gas (cell A6 from the Data sheet).arrow_forwardMicrosoft Excelarrow_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