C   Programming: From Problem Analysis to Program Design
C Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9780357238547
Author: D. S. Malik
Publisher: Cengage Limited
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
(Python matplotlib or seaborn) CPU Usage We have the hourly average CPU usage for a worker's computer over the course of a week. Each row of data represents a day of the week starting with Monday. Each column of data is an hour in the day starting with 0 being midnight. Create a chart that shows the CPU usage over the week. You should be able to answer the following questions using the chart: When does the worker typically take lunch? Did the worker do work on the weekend? On which weekday did the worker start working on their computer at the latest hour?   cpu_usage = [ [2, 2, 4, 2, 4, 1, 1, 4, 4, 12, 22, 23, 45, 9, 33, 56, 23, 40, 21, 6, 6, 2, 2, 3], # Monday [1, 2, 3, 2, 3, 2, 3, 2, 7, 22, 45, 44, 33, 9, 23, 19, 33, 56, 12, 2, 3, 1, 2, 2], # Tuesday [2, 3, 1, 2, 4, 4, 2, 2, 1, 2, 5, 31, 54, 7, 6, 34, 68, 34, 49, 6, 6, 2, 2, 3], # Wednesday [1, 2, 3, 2, 4, 1, 2, 4, 1, 17, 24, 18, 41, 3, 44, 42, 12, 36, 41, 2, 2, 4, 2, 4], # Thursday [4, 1, 2, 2, 3, 2, 5, 1, 2, 12, 33, 27, 43, 8,…
Correct answer only. Code and output screenshot.   Nastia has 2 positive integers An and B. She characterizes that:    The integer is acceptable in case it is detachable by A⋅B;    In any case, the integer is almost acceptable, in case it is detachable by A.    For instance, if A=6 and B=4, the integers 24 and 72 are acceptable, the integers 6, 660 and 12 are almost acceptable, the integers 16, 7 are neither acceptable nor almost great.    Discover 3 unique positive integers x, y, and z to such an extent that precisely one of them is acceptable and the other 2 are almost acceptable, and x+y=z.    Input    The main line contains a solitary integer t (1≤t≤10000) — the number of experiments.    The primary line of each experiment contains two integers An and B (1≤A≤106, 1≤B≤106) — numbers that Nastia has.    Output    For each experiment print:    "Indeed" and 3 distinct positive integers x, y, and z (1≤x,y,z≤1018) to such an extent that precisely one of them is acceptable and the other 2…
2. Detecting whether two numbers entered by the user are friends function printable. If two numbers are equal to the sum of their positive divisors excluding each other, then these numbers are friends. is called. The smallest pair of friend numbers are 200 and 284. These two numbers are friend numbers because 220 is The sum of the positive divisors excluding itself is 284, and the positive divisors of 284 excluding itself are equal to 284. their sum is equal to 220. The sum of the positive divisors of 220 excluding itself: 1+2+4 + 5+ 10 + 11 + 20 + 22 + 44 + 55 + 110 = 284 The sum of the positive divisors of 284 excluding itself: 1+ 2+4 + 71 + 142 = 220 The function returns true if the two numbers entered by the user are friends, false if they are not.
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,