C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
8th Edition
ISBN: 9781337684392
Author: Malik, D. S.
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
[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…
computer science | c++ code | it's not graded. Correct answer will upvoted else downvoted.   It is given a non-negative integer x, the decimal portrayal of which contains n digits. You need to shading every its digit in red or dark, so the number shaped by the red digits is separable by A, and the number framed by the dark digits is detachable by B.    No less than one digit should be shaded in every one of two tones. Consider, the include of digits hued in red is r and the include of digits hued in dark is b. Among all potential colorings of the given number x, you need to output any to such an extent that the worth of |r−b| is the base conceivable.    Note that the number x and the numbers shaped by digits of each tone, may contain driving zeros.  Input :The principal line contains one integer t (1≤t≤10) — the number of experiments. Then, at that point, t experiments follow.    Each experiment comprises of two lines. The main line contains three integers n, A, B (2≤n≤40, 1≤A,B≤40).…
Complete the rotate_text() function that takes 2 parameters, a string data and an integer n. If n is positive, then the function will shift all the characters in data forward by n positions, with characters at the end of the string being moved to the start of the string. If n is 0 then the text remains the same. For example: rotate_text('abcde', rotate_text('abcde', rotate_text('abcde', 1) would return the string 'eabcd' 3) would return the string 'cdeab' 5) would return the string 'abcde' rotate_text('abcde', 6) would return the string 'eabcd' ... and so on. If n is negative, then the function will shift the characters in data backward by n positions, with characters at the start of the string being moved to the end of the string. For example: rotate text('abcde', -1) would return the string 'bcdea'
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,