C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
Expert Solution & Answer
Book Icon
Chapter 12, Problem 10SA

Explanation of Solution

The corrected program is given below with errors and corrections explained in the in-lined comments:

#include <iostream> 

#include <iomanip>

using namespace std; 

int main()  

{  

    //declare double pointer variables

    double *baseRadius;

    double *height;

    //set the print output format

    cout << fixed << showpoint << setprecision(2);

    //allocate memory of type double and store the 

    //address of the allocated memory in baseRadius

    baseRadius = new double;

    //store 1.5 in the allocated memory

    *baseRadius = 1.5;

    //allocate memory of type double and store the 

    //address of the allocated memory in height

    height = new double;

    //store the value of the RHS expression in the allocated memory

    //RHS = 2 &*#x00A0;(1.5) = 3.0

    *height = 2 &*#x00A0;(*baseRadius);

    //allocate fresh memory of type double and store the 

    //address of the allocated memory in baseRadius

    //the earlier address referred to by baseRadius now

    //becomes a case of leaked memory

    //so it is essential to first deallocate the memory

    //using delete operator

    delete baseRadius;

    baseRadius = new double;

    //store 4.0 in the allocated memory

    *baseRadius = 4.0;

    //the code prints the address stored in baseRadius

    //instead of the actual radius of the base

    ///cout << "Radius of the base: " << baseRadius << endl;

    //so the correct code is

    cout << "Radius of the base: " << *baseRadius << endl;

  �...

Blurred answer
Students have asked these similar questions
Figure 1 Q.2/ Find the transfer function, G(s) = Vo(s)/Vi(s), for the network shown in Figure 2. ΙΩ 1 H 0000 + vi(t) + 19 (b) Figure 2 1F vo(t)
Attached is a text file called "Test.txt" that I've created for Python: "There was nothing so very remarkable in that; nor did Alice think it so very much out of the way to hear the Rabbit say to itself, “Oh dear! Oh dear! I shall be late!” (when she thought it over afterwards, it occurred to her that she ought to have wondered at this, but at the time it all seemed quite natural); but when the Rabbit actually took a watch out of its waistcoat-pocket, and looked at it, and then hurried on, Alice started to her feet, for it flashed across her mind that she had never before seen a rabbit with either a waistcoat-pocket, or a watch to take out of it, and burning with curiosity, she ran across the field after it, and fortunately was just in time to see it pop down a large rabbit-hole under the hedge."   I'm trying to create a Markov chain with this code I have here (markov.py) but the program won't run because it doesn't have a direct path to "Test.txt".  Can you help me fix this issue?…
dont use chatgbt to solve this question please and thank you.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr