EBK C   PROGRAMMING:
EBK C PROGRAMMING:
8th Edition
ISBN: 9780357156025
Author: 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
Need expression for "d"  I already have expression for "g"  Do asap. Please.
/(8).
[Fish Tank] You play with a clown fish that has an initial size so. The fish can eat other fish in a tank organized in m columns and n rows. The fish at column i and row j has a positive size si,j. When your fish eats another fish, it grows by that amount. For example, if your clown fish has a size of 10 and eats a fish of size 5, it becomes of size 15. You cannot eat a fish that is bigger than your size. The game starts by eating any fish in the first (left-most) column that is not bigger than yours. After that, you advance one column at a time by moving right. You have only three allowed moves. You either stay at the same row, move one row higher or one row lower. You will always move to the right. Thus, you will make exactly m moves to advance from left to right. Your goal is to exit the fish tank from the right with the biggest possible size. The figure below shows an example with the best answer highlighted. In this case, the final fish size is 71 (10+8+7+24+22). You are required…
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
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,