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
JAVA:
H7.
For the following code:    for ( a = 1, b = 5, c = 3; a < 4; a++, b++ )    {         c = a * b + c;    } Indicate what values for the following variable will be when the code endsa=b=c=
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