Starting Out with C++ from Control Structures to Objects (8th Edition)
8th Edition
ISBN: 9780133769395
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 9.9, Problem 9.13CP
Assume ip is a pointer to an int. Write a statement that will dynamically allocate an integer variable and store its address in ip. Write a statement that will free the memory allocated in the statement you wrote above.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Assume ptr is a pointer to an int and holds the address 12000. On a system with 4-byte integers, what address will be in ptr after the following statement?
ptr += 10;
Pointers may be assigned which of the following values?
Select one:
a.
Any integer values.
b.
An address or NULL
c.
NULL
d.
None of the above c++
Which of the following will exchange the values at addresses identified by pointers p and q? (All assignments may be assumed to be between compatible types).
Select one:
O a. Any will work.
O b. temp = p;
p = q;
q = temp;
O c.
temp = p;
*p = *q;
q = temp;
O d. temp &p;
*p = *q;
q = *temp;
None will work.
O e.
O f. temp = *p;
*p = *q;
*q = temp;
Chapter 9 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Ch. 9.5 - Prob. 9.1CPCh. 9.5 - Write the definition statement for a variable...Ch. 9.5 - List three uses of the symbol in C++.Ch. 9.5 - What is the output of the following code? int x =...Ch. 9.5 - Rewrite the following loop so it uses pointer...Ch. 9.5 - Prob. 9.6CPCh. 9.5 - Prob. 9.7CPCh. 9.5 - Is each of the following definitions valid or...Ch. 9.9 - Prob. 9.9CPCh. 9.9 - Give an example of the proper way to call the...
Ch. 9.9 - Complete the following program skeleton. When...Ch. 9.9 - Look at the following array definition: const int...Ch. 9.9 - Assume ip is a pointer to an int. Write a...Ch. 9.9 - Prob. 9.14CPCh. 9.9 - Prob. 9.15CPCh. 9.9 - Prob. 9.16CPCh. 9.9 - Prob. 9.17CPCh. 9 - What does the indirection operator do?Ch. 9 - Look at the following code. int x = 7; int iptr =...Ch. 9 - So far you have learned three different uses for...Ch. 9 - Prob. 4RQECh. 9 - Prob. 5RQECh. 9 - Prob. 6RQECh. 9 - What is the purpose of the new operator?Ch. 9 - What happens when a program uses the new operator...Ch. 9 - Prob. 9RQECh. 9 - Prob. 10RQECh. 9 - Prob. 11RQECh. 9 - Prob. 12RQECh. 9 - Each byte in memory is assigned a unique...Ch. 9 - The _________ operator can be used to determine a...Ch. 9 - Prob. 15RQECh. 9 - The ________ operator can be used to work with the...Ch. 9 - Array names can be used as ________, and vice...Ch. 9 - Prob. 18RQECh. 9 - The ________ operator is used to dynamically...Ch. 9 - Under older compilers, if the new operator cannot...Ch. 9 - Prob. 21RQECh. 9 - When a program is finished with a chunk of...Ch. 9 - You should only use pointers with delete that were...Ch. 9 - Prob. 24RQECh. 9 - Look at the following array definition: int...Ch. 9 - Prob. 26RQECh. 9 - Assume tempNumbers is a pointer that points to a...Ch. 9 - Look at the following function definition: void...Ch. 9 - Prob. 29RQECh. 9 - Prob. 30RQECh. 9 - Prob. 31RQECh. 9 - T F The operator is used to get the address of a...Ch. 9 - T F Pointer variables are designed to hold...Ch. 9 - T F The symbol is called the indirection...Ch. 9 - T F The operator dereferences a pointer.Ch. 9 - T F When the indirection operator is used with a...Ch. 9 - T F Array names cannot be dereferenced with the...Ch. 9 - Prob. 38RQECh. 9 - T F The address operator is not needed to assign...Ch. 9 - T F You can change the address that an array name...Ch. 9 - T F Any mathematical operation, including...Ch. 9 - T F Pointers may be compared using the relational...Ch. 9 - T F When used as function parameters, reference...Ch. 9 - T F The new operator dynamically allocates memory.Ch. 9 - T F A pointer variable that has not been...Ch. 9 - Prob. 46RQECh. 9 - T F In using a pointer with the delete operator,...Ch. 9 - Prob. 48RQECh. 9 - Prob. 49RQECh. 9 - int x, ptr = nullptr; ptr = x;Ch. 9 - Prob. 51RQECh. 9 - Prob. 52RQECh. 9 - Prob. 53RQECh. 9 - float level; int fptr = level;Ch. 9 - Prob. 55RQECh. 9 - Prob. 56RQECh. 9 - Prob. 57RQECh. 9 - Prob. 58RQECh. 9 - int pint = nullptr; pint = new int[100]; //...Ch. 9 - Prob. 60RQECh. 9 - Prob. 61RQECh. 9 - Prob. 62RQECh. 9 - Array Allocator Write a function that dynamically...Ch. 9 - Test Scores #1 Write a program that dynamically...Ch. 9 - Drop Lowest Score Modify Problem 2 above so the...Ch. 9 - Test Scores #2 Modify the program of Programming...Ch. 9 - Prob. 5PCCh. 9 - Case Study Modification #1 Modify Program 9-19...Ch. 9 - Case Study Modification #2 Modify Program 9-19...Ch. 9 - Mode Function In statistics, the mode of a set of...Ch. 9 - Median Function In statistics, when a set of...Ch. 9 - Reverse Array Write a function that accepts an int...Ch. 9 - Array Expander Write a function that accepts an...Ch. 9 - Element Shifter Write a function that accepts an...Ch. 9 - Movie Statistics Write a program that can be used...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Write a method named square that accepts an integer argument and returns the square of that argument.
Starting Out with Java: From Control Structures through Objects (6th Edition)
Write the function htoi(s), which converts a suing of hexadecimal digits (including an optional 0x or 0X) into ...
C Programming Language
Suppose that a 2 MB file consisting of 512-byte logical blocks is stored on a disk drive with the following cha...
Computer Systems: A Programmer's Perspective (3rd Edition)
Give the complete definition of a class called Person that has two instance variables, one for the persons name...
Java: An Introduction to Problem Solving and Programming (7th Edition)
The _________ is the part of a computer with which the user interacts. a. central processing unit b. user inter...
Starting Out with Programming Logic and Design (4th Edition)
This book declares the main method as public static void main(String[] args) Can it be replaced by one of the f...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
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
- 14. Which of the following operators does not require an Ivalue as its operand? a. address operator (&total) b. assignment (x = .) c. indirection (*ptr) d. postfix increment (x++) e. prefix increment (++x)arrow_forwardwrite a statement that performs the specified task. Assume that double variables number1 and number2 have been declared and that number1 has been initialized to 7.3 . "Display the address stored in doublePtr . Is the address the same as that of number1 ?"arrow_forwardCourse:Data Structure and Algorithms Kindly do this correct as soon as possible: I am providing the a menu base programs in java for address book by using doubly LinkedList and arrayList in a menu which are following: 1.Enter 1 for using Doubly linkedList 2.Enter 2 for using arrayList YOU have to use File handling which create person.text file like this: Perform these steps while application is loading up. You can add a new method loadPersons.• Establish a data channel with a file by using streams• Start reading data (person records) from file line by line• Construct PersonInfo objects from each line you have read• Add those PersonInfo objects in arraylist/ doublylinked list persons.• Close the stream with the fileRead records from a text file named persons.txt. The person records will be present in thefile in the following format. Add at least 50 records in text file, Ali,defence,9201211 Usman,gulberg,5173940…arrow_forward
- question Write a c++ program that follows the program requirements belowarrow_forwardLanguage: C Concatenate two strings using pointers and dynamically allocating the memory for the results. Read two strings from the keyboard using the fgets function. Dynamically allocate the memory for the result using malloc function. Using pointers, copy the first string to the result , except the null terminator ( ’\0’) from the end from the first string. Copy the second string to the result, including the null terminator. Print your results. Free up memory with the free function. Use valgrind to check memory usage.arrow_forwardIN JAVA OR C++ you will simulate a simple multithreading application with a “producer and consumer” problem Modify “Producer and Consumer Problem” from the lecture note so that it can use all buffer space, not “buffersize – 1” as in the lecture note. This program should work as follows: 1. The user will run the program and will enter two numbers on the command line.Those numbers will be used for buffersize and counter limit.2. The main program will then create separate producer and consumer threads.3. The Producer thread generates a random number through a random number generator function, inserts it into the buffer, prints the number, and increment counter.4. The Consumer thread goes to the buffer, takes a number in the proper order, prints it out, and increment counter.5. After the counter reaches its limit, both threads should be terminated and returned to the main.6. Main program terminates.arrow_forward
- write a single statement that performs the specified task. Assume that long variables value1 and value2 have been declared and value1 has been initialized to 200000 ."Assign the address of variable value1 to pointer variable longPtr .arrow_forwardWrite a program in C++ that inputs a number in an integer variable. It stores the address of variable in a pointer and then displays the value and the address of the variable. The screen dialog should appear as follows: Enter an integer 25 The value of n: 25 The address of n: 0x234f6arrow_forwardUsing C++ Programming language: Given the following definitions: int num1=1, num2=2; int *ptr1=NULL, *ptr2=NULL; Write the following statements: Assign ptr1 to the address of num1. Assign ptr2 to the address of num2. Using pointer notation, write a statement that compares the values that the pointers "point" to to see which is larger. (There is more than one way to do this. You choose.)arrow_forward
- You need to write a program in C that will allow a teacher to store, update and view the grades of multiple students. The program should perform the following operations: Add a new student and their grades for different subjects. View the grades of a particular student. Update the grades of a particular student. View the average grades of all students.The program should store the following information for each student: Student name (string) Roll number (integer) Grades for 5 subjects (integers)The program should implement a menu-driven interface for the user to perform the above operations. The program should continue to run until the user selects to exit.Constraints: The student name should not exceed 50 characters. The roll number should be a positive integer and should be unique for each student. The grades should be integers in the range [0, 100].arrow_forwardSegmentation: Select all of the following statements that are true. In segmentation, a logical address always has a length of 32 bit. In order to translate logical into physical addresses, the memory management unit uses the segment part of the logical address to determine the start address in the segment table and adds the offset to this to get the physical address. In segmentation, the logical address consists of a segment part and an offset. The segment length is limited by the maximum possible segment number. When applying segmentation, processes are only allowed to access the memory within their segments. Segments can be assigned access rights and privilege levels.arrow_forward16. NULL can be assigned to a void pointer. True O Falsearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Instruction Format (With reference to address); Author: ChiragBhalodia;https://www.youtube.com/watch?v=lNdy8HREvgo;License: Standard YouTube License, CC-BY