Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
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.
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…
Create two Arrays A with 10 unsorted integer elements and B with 10 unsorted floatelements. Find the largest element in A and B and then sum both of them calling afunction SumAB() by reference. Sort A and B and then call another function StichAB()to merge B with A. Be careful about memory leakage.
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