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;
�...
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
EBK MINDTAPV2.0 FOR MALIK'S C++ PROGRAM
- Analyze the following code. int x = 13B while (0 < x) && (x < 100) System.out .printin(x++); The numbers 2 to 100 are displayed. The code does not compile because the loop body is not in the braces. O The loop runs forever. The code does not compile because (0 < x) && (x < 100) is not enclosed in a pair of parentheses. The numbers 1 to 99 are displayed.arrow_forwardAlert dont submit AI generated answer.arrow_forwardi need answer very quicklyarrow_forward
- Context: Using Python, I am also a beginner in programming. Having a hard time completing this practice and assisstance is appreciatedarrow_forwardBroken Cabins Problem Statement: There is an Office consisting of m cabins enumerated from 1 to m. Each cabin is 1 meter long. Sadly, some cabins are broken and need to be repaired. You have an infinitely long repair tape. You want to cut some pieces from the tape and use them to cover all of the broken cabins. To be precise, a piece of tape of integer length t placed at some positions will cover segments 5,5+1-sit-1. You are allowed to cover non-broken cabins, it is also possible that some pieces of tape will overlap. Time is money, so you want to cut at most k continuous pieces of tape to cover all the broken cabins. What is the minimum total length of these pieces? Input Format The first line contains three integers n,m and k(1sns10°, namsloº, Isksn) - the number of broken cabins, the length of the stick and the maximum number of pieces you can use The second line contains n integers bl,b2,bn (Isbism) - the positions of the broken cabins. These integers are given in increasing…arrow_forwardQuestion 11 mah .Full explain this question and text typing work only We should answer our question within 2 hours takes more time then we will reduce Rating Dont ignore this linearrow_forward
- "NEED ONLY CODE NO EXPLANATION" Harry has a big wall clock, that got hit while he was playing. Now, the minute hand doesn't rotate by the angle 2π/3600 each second, but now it moves according to different angle x. You can assume that coordinates of the centre of the clock are (0, 0) and the length of the minute hand is l. One endpoint of the minute hand is always located at the clock centre; the other endpoint is initially located at the point (0, l). One second later, Harry observes that this endpoint is at distance d above the x-axis, i.e., the y-coordinate of this endpoint is equal to d. Harry is curious about where the minute hand will be (specifically, its y-coordinate) after t seconds. Because t can be very large, Harry can't wait for that moment. Please help him to write a python code that prints a single line containing the output. Input: 4 2 2 Output 4arrow_forwardWhat a solution with java language please ?arrow_forwardAnswer in C languangearrow_forward
- The following PThreads code is written for book reservation in a library. Each student checks if the book is free. If it was free they will reserve it with their own ID and the book becomes unavailable to the rest. a. Can you identify the problem with this code? Explain the condition that the code may fail. b. Rewrite the code (just a few lines of code) to solve the problem. //PThreads code here if (book.state==free) ( book.state%-reserved; book.borrower%=MyID;arrow_forwardC - Given 4 integers, output their product and their average using integer arithmetic.arrow_forwardThe following statement is valid. int x, X; True Falsearrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,