EP MINDTAPV2.0 FOR MALIK'S C++ PROGRAMM
EP MINDTAPV2.0 FOR MALIK'S C++ PROGRAMM
8th Edition
ISBN: 9780357425237
Author: Malik
Publisher: Cengage Learning
bartleby

Concept explainers

Expert Solution & Answer
Book Icon
Chapter 12, Problem 15SA

Explanation of Solution

The problem with the program has been explained in the in-lined comments:

#include <iostream> 

using namespace std; 

int main()  

{  

    //pointer variables declared and memory allocated

    double *firstPtr = new double; //Line 1

    double *nextPtr = new double; //Line 2

    //value assigned to pointer variable

    *firstPtr = 62; //Line 3

    //nextPtr is assigned the pointer firstPtr

    //so nextPtr points to a memory location

    //having a stored value of 62

    nextPtr = firstPtr; //Line 4

    //memory pointed to by both the pointers are

    //deallocated

    delete firstPtr; //Line 5

    delete nextPtr; //Line 6

    //fresh memory i...

Blurred answer
Students have asked these similar questions
/*Line 1:*/ doublevalues[6] = {10, 20, 30, 40, 50, 60}; /*Line 2:*/ double* yalptr= values; /*Line 3:*/ cout << 3*values[1] + yalptr[3] + *(valptr + 2); A. What is 3*values[1] equal to in Line 3? (Explain) B. What is yalptr[3] equal to in Line 3? (Explain)
What does the function f do? struct Point2D { double x; double y; struct Triangle { Point2D v1; Point2D v2; Point2D v3; }; void f(Triangle&t) { } int temp = 12.5; temp = t.v1.x; t.v1.x = t.v1.y; t.v1.y = temp; } int main () { Triangle mytri; mytri.v1.x = 1.0; mytri.v1.y = 22.5; f (mytri); Swaps values of x and y in vertex 1 of an argument of type Triangle Initializes value of x in vertex 1 of an argument of type Triangle Sets all x,y values in all vertices of an argument of type Triangle Swaps value of x in vertex 1 with value of x in vertex 2, for an argument of type
if L1={ab,b} L2={abb,bb} then L1L2= * O {ababb,abbb,abbab,bbab} O {ab,b,abb,bb} O {ababb,abbb,babb,bbb} O {abbab,abbb,bbab,bbb}
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