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...
Trending nowThis is a popular solution!
Chapter 12 Solutions
C++ Programming: From Problem Analysis to Program Design
- What is the screen output of the following codearrow_forwardWhat will the following code print? Show your work.arrow_forwardIn the following code stream, identify if there are any hazards. Crisply describe if it is possible to get around the hazards, and what the resulting steps will be. lw r2, 0(r1) add r3, r2, r3 sub r1, r1, r4arrow_forward
- This Code print the first occurrences of x, Please Modify the code to print the last occurrences of x and print how many times it exists? ( with explanation for each line if possible) many thanks.arrow_forwardFor the given the following code segment, what is the output? And Why?arrow_forwardtrace the following code and give the output. for (int a = 1; a <= 3; a++) for (int b = 1; b <= 3; b++) cout << a+b << endl;arrow_forward
- Trace the following code and give the output int a = 6, b = 8; int c = (a < b) ? a : b; int v = c; while (v%a != 0 || v%b != 0) v += c; cout << v;arrow_forwardAnalyze the following code and fill in the output. I got the answers wrongarrow_forwardConvert the following code into descriptive code, and verify using White Box Testing. int a[10]={23, 45, 10, 0, 98, 36, 2, 56, 34, 12}; for (int i=0; i a[j+1]) swap(&a[j], &a[j+1]); end-if end-for end-forarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT