Concept explainers
The code that follows shows an example of branching on an enumerated type value in a switch statement. Recall that enumerated types in C are simply a way to introduce a set of names having associated integer values. By default, the values assigned to the names count from zero upward. In our code, the actions associated with the different case labels have been omitted.
The part of the generated assembly code implementing the differents actions is shown in Figure 3.52. The annotations indicate the argument locations, the register values, and the ease labels for the different jump destinations.
Fill in the missing parts of the C code. It contained one case that fell through to another—try to reconstruct this.
Figure 3.52 Assembly code for Problem 3.62. This code implements the different branches of a switch statement.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Additional Engineering Textbook Solutions
C++ How to Program (10th Edition)
Starting out with Visual C# (4th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Problem Solving with C++ (9th Edition)
Concepts Of Programming Languages
- Problems include bad pointers, writing to the end of allotted memory, and memory leaks.When it comes to memory management, C++ provides a great deal of freedom. You can allocate and deallocate memory as well as directly manage pointers.Flexibility comes at a price. Because the language permits you to allocate memory, you can make mistakes. Similarly, you may mess up deallocation and pointer usage. What do you do to secure your code in C++ when there are no built-in safety checks?arrow_forwardI'm stuck on this question and I don't know how I should be approaching this. What should I do? Our focus is on pointers and dynamic arrays through C++arrow_forwardHow can one quickly copy a bunch of shared references into another array in C++? Make a list of potential remedies for the current circumstance. Does copying shared pointers really copy the objects they handle as well? Explainarrow_forward
- Write a C or C++ program that does many references to elements of two-dimensional arrays, using only subscripts. Write a second program that does the same operation but uses pointers and pointer arithmetic for the storage-mapping function to do the array references. Compare the time efficiency of the two programs. Which of the two programs is likely to be more reliable? Why?arrow_forwardWrite three functions in C or C+: one that declares a large array statically, one that declares the same large array on the stack, and one that creates the same large array from the heap. Call each subprogram a large number of times (at least 100,000) and output the time required by each. Explain the results.arrow_forwarda. With respect to scope, why are modules (or namespaces) useful? b. Why do locally declared arrays in C++ need to have a fixed size? c. Explain why C++ still has to perform type inference even though each variable must be explicitly declared with a type.arrow_forward
- Using a pointer as the return value is considered a poor practise in C. For example, how does dynamic memory allow us to return an object pointer from a function safely?arrow_forwardExplain in more detail why C++ only allows arrays to be passed as reference parameters.arrow_forwardAbstraction is an important tool against complexity. It helps encapsulate constructs which would be very difficult in its absence. Simulating the behavior of complex numbers(a + bi) illustrates this very concept. Write an abstract data type for complex numbers, including operations for addition, subtraction, multiplication, division, extraction of each of the parts of a complex number, and construction of a complex number from two floating-point constants, variables, or expressions. Use C++ or Java.arrow_forward
- 118. Prototyping model is based on a. limited functionality b. unlimited functionality c. linear combinations d. non linear sequential statementsarrow_forwardwrite a class implementation using C++ from the given class diagram TAKE NOTE OF THE FF SPECIFICATIONS: Using the constructor, create three objects from class Voters and store it in the stack memory. Two voters must have an active account and one voter has a deactivated account. Please note that the deactivated voter account must be still part of the “object”. Test all the functions by making calls. this should be the sample resultarrow_forwardSo, in C++ I understand using pointers and references in as function arguments, but need a bit of in depth explanation as to understanding dynamic memory allocation, and how to know when they are allocated? It is because I am confused on how memory works whenever I use pointers or references or allocating memory in C++?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education