• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 18 pages
Exam (elaborations)

Absolute_C___5th_Edition_By_Walter_Savitch_____Test_Bank

Document preview thumbnail
Preview 3 out of 18 pages

Chapter 3 – Function Basics –Test Questions These test questions are true-false, fill in the blank, multiple choice, and free form questions that may require code. The multiple choice questions may have more than one correct answer. You are required to mark and comment on correct answers.. Mark all of the correct answers for full credit. The true false questions require an explanation in addition to the true/false response, and, if false, also require a correction. True False: An explanation is required. 1. Every programmer must know all the details of what that programmer’s team mates are doing in their projects to do the work assigned. Why? Answer:. False Explanation: Only the client programmer needs to know the use to which a function is put. Only the author of the function needs to know the internals. The only thing these two share is the contract or specification of the function. 2. Procedural abstraction involves information hiding in that only the ‘contract’ between the programmer using the function (the client) and author of a function is known to either. Answer: True. Explanation: Under procedural abstraction, the author (or programmer) of a given function should know about how the application programmer (or the client) will use the function is IN the ‘contract.’ The contract is what the function is to do, and the conditions set on the parameters to guarantee that the function can do IT. The author should not need not know how the function is to be used by the client programmer. The client programmer should know only only needs to know what the function does, the requirements on the parameters, but not how the function carries out the task. This way each can do his job independently of the other. 3. Code after a return or a call to the exit function is executed will not be executed. Answer: True. Control returns to the caller if return is executed out of a called function, and returns to the operating system if return is executed out of main. If exit is executed anywhere, the program is terminated and control is returned to the operating system. 4. A sequence of calls to the library function rand() generates mathematically correct random number sequences. Answer: False. Explanation: The sequence is called pseudorandom because it appears to be random. The results are good enough to obtain usable answers with computer simulation. 5. It is legal to replace the prototype double totalCost(int numberParam, double priceParam); with the more terse, alternate form double totalCost(int, double); Answer: True. Explanation: The alternate form applies only to function declarations. You will see this form in manuals. It is possible to omit variable names that will not be used in function definitions, but the text does not do this. 6. In C++ Boolean value are represented only with the int values 0 for false and 1 for true. Answer: False. Explanation: In C++ the bool type is a real type, with values true and false, but 0 is interpreted as true and 0 as false, and true and false will be converted to 1 and 0 respectively. 7. Extensive use of global variables is a satisfactory replacement for the difficulties of parameter passing with functions. Answer: False. Explanation: Global variable use ties functions together so tightly that it is impossible to understand any one function’s behavior apart from the whole of the program. This complexity makes understanding a program very difficult. 8. A variable declared outside any function is said to be a local variable. Answer: False. Explanation: This is a global variable. 9. A variable declared within a function block is said to be local to the function. Answer: True Explanation: Such a variable is said to be local to the function or to have the function as its scope, and is also known as a local variable if the scope is clear from the context. 10. Consider two blocks, one within another. If an identifier is declared as a variable in the inmost of these two blocks, one can access this variable from the outer block. Answer: False: Explanation: The scope of a local variable extends from the definition to the end of the block in which the variable is defined. This excludes the outer block. 11. Consider two blocks, one within another. C++ prohibits an identifier to be declared as a variable in each of these blocks. Answer: False Explanation: Without the inner variable, the scope of the outer variable would be the entire outer block, including the inner block. The variable with the inner block for its s


Document information

Uploaded on
July 1, 2024
Number of pages
18
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers
$15.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
BRAINBOOSTERS
4.5
(355)
Sold
799
Followers
258
Items
25920
Last sold
1 day ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions

Whoops! We can’t load your doc right now. Try again or contact support.