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

Explanation of Solution

The program errors and the corrections are explained in the in-lined comments:

#include <iostream> 

using namespace std; 

int main()  

{  

    //speed is a int pointer which is declared and 

    //memory allocated

    int *speed = new int; //Line 1

    //double pointers are declared 

    double *travelTime; //Line 2

    double *distance; //Line 3

    //value of 65 is stored in the memory allocated

    //pointed to by speed using address of operator

    //& which is wrong

    ///&speed = 65; //Line 4

    //correct line is 

    *speed = 65;

    //value is attempted to be stored at a memory location

    //which is pointed to by travelTime but actually

    //no memory has yet been allocated so memory

...

Blurred answer
Students have asked these similar questions
Q2/find the transfer function C/R for the system shown in the figure Re ད
Please original work select a topic related to architectures or infrastructures (Data Lakehouse Architecture). Discussing how you would implement your chosen topic in a data warehouse project Please cite in text references and add weblinks
Please original work What topic would be related to architectures or infrastructures. How you would implement your chosen topic in a data warehouse project. Please cite in text references and add weblinks
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