C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 12, Problem 3SA
Explanation of Solution
To create a pointer using * we give the datatype followed by the * and ending with the pointer variable name, example, int * p. The * can be attached to the datatype on the left or the variable name on the right inst...
To create a pointer using * we give the datatype followed by the * and ending with the pointer variable name, example, int * p. The * can be attached to the datatype on the left or the variable name on the right inst...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What do you understand by dangling and wild pointers? How they are known to be problems with pointers? Explain with the help of example.
Q4. What operators we can use with pointers. Explain the effect of ++(increment) and -
(decrement) with pointers of different data types.
"Pointers are known to have issues with dangling and wild pointers." With the use of appropriate examples, justify the stated statement.
Chapter 12 Solutions
C++ Programming: From Problem Analysis to Program Design
Ch. 12 - Prob. 1TFCh. 12 - Prob. 2SACh. 12 - Prob. 3SACh. 12 - Prob. 4SACh. 12 -
Suppose that you have the declaration int...Ch. 12 -
What is the output of the following C+ + code?...Ch. 12 -
Given the following statements:
write C+ +...Ch. 12 - Prob. 8SACh. 12 - Prob. 9SACh. 12 - Prob. 10SA
Ch. 12 - Prob. 11SACh. 12 - Prob. 12SACh. 12 - Prob. 13SACh. 12 - Prob. 14SACh. 12 - Prob. 15SACh. 12 - What is the output of the following code? (2, 3,...Ch. 12 - Prob. 17SACh. 12 - Prob. 18SACh. 12 - Prob. 1PECh. 12 - Prob. 2PECh. 12 -
Programming Exercise 11 in Chapter 8 explains how...Ch. 12 - Prob. 5PE
Knowledge Booster
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
- It's well knowledge that "dangling and wild pointers" are problematic for pointers. Use specific examples to back up your argument.arrow_forwardWhat exactly is a pointer? How should a pointer be declared and initialised? Give an example.arrow_forwardWith an example discuss the operators used with pointers.arrow_forward
- Write a paper that summarizes the chapter (or an online resource) that may help you understand the concept of pointers. Include the following topics in the paper. Include illustrations either from the book, or an online source or your own illustration. Come up with an introduction Pointer Variable Declarations and Initialization Pointer Operators Pass-by-Reference with Pointers Built-In Arrays Using const with Pointers sizeof Operator Pointer Expressions and Pointer Arithmetic Relationship Between Pointers and Built-In Arrays Pointer-Based String About Smart Pointersarrow_forwardAnswer the following as completely as possible in your own words:1. Explain how an array is sent to a function as a parameter.2. State which parameters should almost always be sent to any function which modifies an array. Explain why.3. Explain the similarity between index notation and pointer arithmetic.arrow_forwardDiscuss the following. a. Pointersb. Arraysc. Structuresd. Classese. functionsarrow_forward
- Give an illustration of the concept of "Pointers."arrow_forwardQUESTION 17 The use of smart pointers makes the implementation of the clear method overly complex. O True O False QUESTION 18 There are two types of traditional pointers - raw pointers and well-done pointers. O True False QUESTION 19 When is the reference count of an object managed by a shared pointer decreased by 1? O When a shared pointer goes out of scope or when a shared pointer is assigned an invalid value O None of these When a shared pointer goes out of scope or when a shared pointer is assigned the value nullptr O When a shared pointer's copy constructor is invoked or when a shared pointer is assigned the value nullptr QUESTION 20 What is an object's reference count? The number of times it is used in a line of code The number of raw pointers that reference objects referenced by smart pointers The number of pointers that own an object O The number of aliases that reference itarrow_forwardPointer arithmetic. Implement the following:a. Implement a print function with array and size parameters. This function should print the array using pointer arithmetic.b. Overload the print function to accept array, size and index parameters. If the index is between 1 and size-2 inclusive: Use pointer arithmetic to print: 1. the value at index 2. the value previous to the index 3. the value after the index c. Implement a sum function with array and size parameters. This function should return sum of the array, and use pointer arithmetic.d. Implement a average function with array and size parameters. This function shouldreturn average of the array, and use pointer arithmetic.e. Use provided main function to test your functions. ( Do not change the int main the question has provided. Included a snip of the int main function. Output has to be the same as shown in the snips)arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr