Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 9.2, Problem 11STE
Program Plan Intro

Pointer in C++:

A pointer is a variable whose value will be another variable’s address. Generally, a pointer variable is declared as follows:

type *var-name;

Here, “type” is the pointer’s base type and “var-name” is the pointer variable name. The asterisk is used to designate a variable as a pointer.

The delete operator:

The delete operator is used to destruct the object that is created with new by deallocating the memory associated with the object.

The syntax of delete operator is as follows:

[] delete cast-expression

[] delete[] cast-expression

In the above statement, the “cast-expression” argument must be a pointer to a block of memory previously allocated for an object created with the new operator.

Given code:

The following code is used to create a dynamic array.

int *entry; //Initialise pointer

entry = new int[10]; //create a dynamic array

Blurred answer
Students have asked these similar questions
Write a C++ program that can delete an element from an array. The user nominates the values to save in the array (as in Assignment 1). The element that has to be removed from the array (nth element) is also provided by the user. The program must ensure that the value for n is valid. After the value has been deleted, the array must be displayed to the user again. Tip: To erase an element, the elements are moved to overwrite the nth element. Note that the array can now save one more position than there are elements. The number of "active" elements in the array must be updated every time.
Following is the partition function for quicksort, where we have used the leftmost number as a pivot. Assume that our array, ARR = {14, 8, 7, 38, 22, 15, 9}, which is 7 in size. What will be the array ARR after we apply "partition(A, 0,  6)"*           9, 15, 22, 38, 7, 8, 14       7, 8, 9, 14, 15, 22, 38       9, 8, 14, 7, 22, 15, 38       9, 8, 7, 14, 22, 15, 38       7, 9, 15, 22, 38, 14, 6       38, 22, 15, 14, 9, 8, 7
Question This exercise  give you practice working with a two-dimensional array. the Example 7.14 on two-dimensional arrays, recall that I loaded the array using an Initializer list.  Modify Example 7.14.  Instead of using an initializer list to load the array, create 2 functions: loadArray – function “loadArray“ will have 1 parameter which will be the grade array. The function will allow the user to enter 12 quiz grades (3 for each student), store each quiz grade in the appropriate element of the grade array, and return an int representing the number of quizzes entered (12).  “loadArray” will use nested loops to prompt the user to enter the 12 grades.  It will count each grade entered and return the number of quizzes entered. loadFromFile – function “loadFromFile” will have 1 parameter which will be the grade array. The function will return an int representing the number of quizzes read(12).  “loadFromFile” will use nested loops to read the values from the file and store each quiz…
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education