EBK C++ PROGRAMMING: FROM PROBLEM ANALY
8th Edition
ISBN: 9781337514491
Author: Malik
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 12, Problem 15SA
Explanation of Solution
The problem with the program has been explained in the in-lined comments:
#include <iostream>
using namespace std;
int main()
{
//pointer variables declared and memory allocated
double *firstPtr = new double; //Line 1
double *nextPtr = new double; //Line 2
//value assigned to pointer variable
*firstPtr = 62; //Line 3
//nextPtr is assigned the pointer firstPtr
//so nextPtr points to a memory location
//having a stored value of 62
nextPtr = firstPtr; //Line 4
//memory pointed to by both the pointers are
//deallocated
delete firstPtr; //Line 5
delete nextPtr; //Line 6
//fresh memory i...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
/*Line 1:*/ doublevalues[6] = {10, 20, 30, 40, 50, 60};
/*Line 2:*/ double* yalptr= values;
/*Line 3:*/ cout << 3*values[1] + yalptr[3] + *(valptr + 2);
A. What is 3*values[1] equal to in Line 3? (Explain)
B. What is yalptr[3] equal to in Line 3? (Explain)
What does the function f do?
struct Point2D
{
double x;
double y;
struct Triangle
{
Point2D v1;
Point2D v2;
Point2D v3;
};
void f(Triangle&t)
{
}
int temp = 12.5;
temp = t.v1.x;
t.v1.x = t.v1.y;
t.v1.y = temp;
}
int main ()
{
Triangle mytri;
mytri.v1.x = 1.0;
mytri.v1.y = 22.5;
f (mytri);
Swaps values of x and y in vertex 1 of an argument of type Triangle
Initializes value of x in vertex 1 of an argument of type Triangle
Sets all x,y values in all vertices of an argument of type Triangle
Swaps value of x in vertex 1 with value of x in vertex 2, for an argument of type
if L1={ab,b} L2={abb,bb} then
L1L2= *
O {ababb,abbb,abbab,bbab}
O {ab,b,abb,bb}
O {ababb,abbb,babb,bbb}
O {abbab,abbb,bbab,bbb}
Chapter 12 Solutions
EBK C++ PROGRAMMING: FROM PROBLEM ANALY
Ch. 12 - Prob. 1TFCh. 12 - Prob. 2SACh. 12 - Prob. 3SACh. 12 - Prob. 4SACh. 12 -
Suppose that you have the declaration int...Ch. 12 -
What is the output of the following C+ + code?...Ch. 12 -
Given the following statements:
write C+ +...Ch. 12 - Prob. 8SACh. 12 - Prob. 9SACh. 12 - Prob. 10SA
Ch. 12 - Prob. 11SACh. 12 - Prob. 12SACh. 12 - Prob. 13SACh. 12 - Prob. 14SACh. 12 - Prob. 15SACh. 12 - What is the output of the following code? (2, 3,...Ch. 12 - Prob. 17SACh. 12 - Prob. 18SACh. 12 - Prob. 1PECh. 12 - Prob. 2PECh. 12 -
Programming Exercise 11 in Chapter 8 explains how...Ch. 12 - Prob. 5PE
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 1. Formula for cell A15 that adds all data from B1 to D6 2. Formula for cell A16 that determines the lowest number found on A1, A2, A3, B1, B2, and B3 3. If you had a cell reference C5, but in your formula you want C to stay constant and 5 to change, what would be the correct structure? 4. If you have a list of numbers in cells B2 through B20 and you wanted the average of these numbers, what would be the formula? 5. Assume you are copying cell A1 to cell C3. If cell A1 contains the formula =$B1+$C$1, how would this formula change when copied to cell C3?arrow_forwardВ.width; } { t = B.type; w = { T.type = C.type; T.width = C.width; } T → B C В > int { B.type = integer; B.width 4; } В — foat { B.type = float; B.width = 8; } { C.type = t; C.width = w; } C - [ num] C1 = array(num. value, C1.type); { C.type C.width = num. value x C1. width; }arrow_forwardC++ only. Do not copy. Correct code will upvoted else downvote. Monocarp is playing a PC game. Presently he needs to finish the principal level of this game. A level is a rectangular framework of 2 lines and n sections. Monocarp controls a character, what begins in cell (1,1) — at the convergence of the 1-st line and the 1-st segment. Monocarp's character can move starting with one cell then onto the next in one stage if the cells are nearby by side or potentially corner. Officially, it is feasible to move from cell (x1,y1) to cell (x2,y2) in one stage if |x1−x2|≤1 and |y1−y2|≤1. Clearly, it is denied to go external the matrix. There are traps in certain cells. In case Monocarp's character winds up in such a cell, he bites the dust, and the game closures. To finish a level, Monocarp's character should arrive at cell (2,n) — at the crossing point of line 2 and section n. Assist Monocarp with deciding whether it is feasible to finish the level. Input The principal…arrow_forward
- C++ Programming Problem: Newton is a brilliant mathematician and solving triangles problems fascinates him. Today he is given a sequence of positive integers V1, V2, ., VN. You must choose three elements Vx, Vy, Vz (x, y, z is vertices) such that the triangle formed have these properties: |XY|= Vz, |XZ|=Vy, |YZ|=Vx and the angle |ZYXZ|= 0 satisfies cose2P/Q, where 0 should be maximum possible. Find any such triangle or determine that it does not exist. Develop a C++ code which prints the value of x, y, z in a single line and print "Invalid" if not possible. Test Case: 412 9765 Result: 324arrow_forwardC LANGUAGEA private railway company has just purchased a computer for its new automated reservationssystem. You have been asked to write a program to assign seats on each train of the railway havingonly (capacity: 100 seats). Your program should check whether it is a valid seat number or not.Also print its berth type i.e lower berth, middle berth, upper berth, side lower berth, side upperberth. Furthermore, then print a ticket indicating the person's seat number and whether it’s in the firstclass or economy section of the train. Use a single-subscripted array to represent the seating chartof the train. Initialize all the elements of the array to 0 to indicate that all seats are empty. As eachseat is assigned, set the corresponding element of the array to 1 to indicate that the seat is no longeravailable.arrow_forwardC++ programming Chapter(s) Covered: Chapter 1-8 Concepts tested by the program: Working with one dimensional parallel arrays Use of functions Use of loops and conditional statements Project Description The Lo Shu Magic Square is a grid with 3 rows and 3 columnsshown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly. Each number 1 – 9must not be used more than once. So, if you were to add up thenumbers used, The sum of each row, each column and each diagonal all add upto the same number, Write a program that simulates a magic square using 3 onedimensional parallel arrays of integer type. Each one the arrays corresponds to a row of the magicsquare. The program asks the user to enter the values of the magicsquare row by row and informs the user if the grid is a magicsquare or not. See the sample outputs for more clarification. Project Specifications Input for this project: Values of the grid (row by row) Output for this…arrow_forward
- C++ code. Please describe what EACH line means/does. Ignore code that is commented out.arrow_forwardFind the C program language Breaking the Code by CodeChum Admin ATTENTION SOLDIER! This will be the hardest mission of your life. Our intelligence department has caught the enemy sending codes from one base to another. These enemy codes can either be a simple communication message or a mastermind plan. Our intelligence department has determined that a mastermind plan is a code that has at least 1 consonant character. Since you know programming, your task is to check a code if it is a mastermind plan or not.arrow_forwardc++ programming Write a function named maxCols which stores the maximum value in each row of a 3x3 2D array into a 1D array. This function should accept a 3x3 2D array, a 1D array and the size of each dimension as parameters. Example Calling maxCols with this 2D array:3 7 2 9 3 6 8 5 6 Results in the 1D array storing the values 7,9,8.arrow_forward
- In C++Using the code provided belowDo the Following: Modify the Insert Tool Function to ask the user if they want to expand the tool holder to accommodate additional tools Add the code to the insert tool function to increase the capacity of the toolbox (Dynamic Array) USE THE FOLLOWING CODE and MODIFY IT: #define _SECURE_SCL_DEPRECATE 0 #include <iostream> #include <string> #include <cstdlib> using namespace std; class GChar { public: static const int DEFAULT_CAPACITY = 5; //constructor GChar(string name = "john", int capacity = DEFAULT_CAPACITY); //copy constructor GChar(const GChar& source); //Overload Assignment GChar& operator=(const GChar& source); //Destructor ~GChar(); //Insert a New Tool void insert(const std::string& toolName); private: //data members string name; int capacity; int used; string* toolHolder; }; //constructor GChar::GChar(string n, int cap) { name = n; capacity = cap; used = 0; toolHolder = new…arrow_forwardC Programming Language (Code With C Programming Language) Problem Title : Visible Trees There is a legend about a magical park with N × N trees. The trees are positioned in a square grid with N rows (numbered from 1 to N from north to south) and N columns (numbered from 1 to N from west to east). The height (in metres) of each tree is an integer between 1 and N × N, inclusive. Magically, the height of all trees is unique. Bunga is standing on the northmost point of the park and wants to count the number of visible trees for each Column. Similarly, Lestari is standing on the westmost point of the park and wants to count the number of visible trees for each Row. A tree X is visible if all other trees in front of the tree X are shorter than the tree X. For example, let N = 3 and the height (in metres) of the trees are as follows6 1 87 5 32 9 4 On the first column, Bunga can see two trees, as the tree on the third row is obstructed by the other trees. On the second column, Bunga can see…arrow_forwardGiven the definition below: float train[10] = {4.4, 6.1, 3.9, 8.6, 5.0}; float *pTrain = train; Using pTrain, increment the value of the third element by 1.1.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education