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 11SA

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 type pointer variables

    double *length;

    double *width;

    //set the output format

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

    //allocate memory to be referred to by length

    length = new double;

    //the statement is incorrect as length is pointer

    //variable and not a double variable

    ///length = 6.5;

    //so the correct code is

    *length = 6.5;

    //statement is incorrect as & is an address of operator

    /// &width = 3.0;

    //so the correct set of statements are shown below

    //where first memory is allocated and then the value

    //is assigned

    width = new double;

    *width = 3...

Blurred answer
Students have asked these similar questions
can you draw the shortest path tree using BFS for the following directed unweighted graph?
What is the shortest path from vertex 3 to all other vertices:Which graph algorithm can solve the problem most efficiently(the quickest runtime)How could the same algorithm if the graph had edge weights? (create intermediate nodes)
The difference between (1) a database management system (DBMS) and (2) a database, is:     a. The first refers to a complete accounting system, the second refers to a subset of that b. The first is program software, the second is proprietary data and related files c. The first is hardware, the second is software d. Nothing—these terms are synonyms..
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,