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
...Trending nowThis is a popular solution!
Chapter 12 Solutions
EBK C++ PROGRAMMING: FROM PROBLEM ANALY
- The value of x at the end.int x = 1;x = x + 1;x++;arrow_forward3) What is the output of the following code segment? Why? int value1 = 5, value2 = 15; int *p1, *p2; p1 = &value1; %3D p2 = &value2; *p1 = 10; %3D *p2 = *p1; %3D p1 = p2; *p1 = 20; %3Darrow_forwardC Language - Write a program that takes in three integers and outputs the largest value. If the input integers are the same, output the integers' value.arrow_forward
- int main(){ if(var1>50) { num = 20.0 } else { if(var1>35) ---- Line 7 { num= 35.0; } else if (var1<80) { num=60.0; } else { num=40.0; }} What should be the outcome of the condition in line 7 in order for the value of num to be equal to 60.0?arrow_forwardVoid Do1 (int: &, a. int &b) { a = 5; a = a + b; b = a + 2; } Int main() { Int x = 10; Do1 (x,x); Cout << x << endl; } The output of this program isarrow_forwardLab activity: Driving costs Code in main.py, attach output.arrow_forward
- #include<stdio.h> #include<stdlib.h> main() { int m, sum = 0, counter = 0; int first = 2147483647, second = 2147483647, third = 2147483647, min = 2147483647; double average;printf("Enter an int or -1 to stop:\n"); while (1) {scanf_s("\n%d", &m);if (m == -1) { break; } sum = sum + m; counter++; if (m < first first == second first == third ) { third = second; second = first; first = m; } else if (m < second && m !=first ) { third = second; second = m; } else if (m < third && m != second) { third = m; } else if (first == second == third) { printf("min is: %d", first); }}printf("Sum of value: %d \n", sum); average =(double) sum /(double)counter; printf("Avarege is: %.2lf \n", average); printf("First min is: %d\n", first); printf("Second min is: %d\n", second); printf("Third min is: %d\n", third);system("pause"); } can you run this code pleasearrow_forwardC# questionarrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning