Explanation of Solution
The program execution is explained in the in-lined comments:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//declare pointer variables and allocate memory
double *trip1Cost = new double;
double *trip2Cost = new double;
double *trip3Cost = new double;
double *max;
//store values in the allocated memory
*trip1Cost = 100.00;
*trip2Cost = 350.00;
//assign pointer variables to each other
//trip3Cost now points to location having
//stored 350.00 later trip2Cost points
//to location having a stored value 100.00
trip3Cost = trip2Cost;
trip2Cost = trip1Cost;
//trip1Cost is now pointed to freshly allocated
//memory location and assigned value
trip1Cost = new double;
//trip1Cost points to a location having
//stored value of 175 and trip3Cost now
//points to a location having a stored value 275
*trip1Cost = 175;
*trip3Cost = 275;
//sets the output format
cout << fixed << showpoint << setprecision(2);
//prints the arithmetic expression
//(*trip1Cost + *trip2Cost + *trip3Cost) which
//evaluates to (175 + 100...
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
C++ Programming: From Problem Analysis to Program Design
- a C++ function, reverseDigit, that takes four digit integer as a parameter and returns the number withits digits reversed. For example, the value of reverseDigit(1234) is 4321 Note: explain each step by applying a double line commentsarrow_forwardC++ You are required to write three overloaded functions called stringOperation that take in the following formal parameters list: Function 1: takes as input a string, ONE character, and an integer n, and returns true if the string contains that character EXACTLY an n number of times. Function 2: takes as input a string and TWO alphabatical characters c1 and c2, and returns true if all the string characters fall in the range between the two passed characters (exclusive) (You must make sure to order the characters first if c2 < c1 ). Function 3: takes as input a string and THREE alphabatical characters c1, c2 and c3. The function reorders the characters in asecnding order, such that c1 holds the smallest character and c3 holds the largest character. The function returns true if the string characters that fall between c1 and c2 (exclusive) is less than the string characters that fall between c2 and c3 (exclusive). Do not write and submit the main subroutine, or any include…arrow_forwardCode using c++ 3. From Person to People by CodeChum Admin Now that we have created a Person, it's time to create more Person and this tech universe shall be filled with people! Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age and character value for its gender. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. In the main() function, there's a pre-created array of 5 Persons. Your task is to ask the user for the values of the age and gender of these Persons. Then, once you've set their ages and genders, call the displayPerson() function and pass them one by one. Input 1. A series of ages and genders of the 5 Persons Output Person·#1 Enter·Person's·age:·24 Enter·Person's·gender:·M Person·#2 Enter·Person's·age:·21 Enter·Person's·gender:·F Person·#3 Enter·Person's·age:·22 Enter·Person's·gender:·F Person·#4…arrow_forward
- C++ : Write a function that has three C++ strings as parameters. It searches the first parameter to find the secondparameter (as a substring) and replaces it with the third parameter. It returns the changed first parameter if the substringcan be found; otherwise, it returns the original first parameter. Test your function in a program.arrow_forwardin c++ write three overloaded functions called stringOperation that take in the following formal parameters list: Function 1: takes as input a string, ONE character, and an integer n, and returns true if the string contains that character EXACTLY an n number of times. Function 2: takes as input a string and TWO alphabatical characters c1 and c2, and returns true if all the string characters fall in the range between the two passed characters (exclusive) (You must make sure to order the characters first if c2 < c1 ). Function 3: takes as input a string and THREE alphabatical characters c1, c2 and c3. The function reorders the characters in asecnding order, such that c1 holds the smallest character and c3 holds the largest character. The function returns true if the string characters that fall between c1 and c2 (exclusive) is less than the string characters that fall between c2 and c3 (exclusive). Do not write and submit the main subroutine, or any include statments, these are…arrow_forwardQ3: Write a C++ code of an integer function that has two integer parameters passed by reference, and returns the remainder (mode) of the first parameter divided by the second parameter. *arrow_forward
- C++ printSmaller is a function that accepts two int parameters and returns no value. It will print the value of the smaller one parameters. The function protoype is as follows: void printSmaller(int num1, int num2); write the statments to read two integers and call this function to display the smaller one.arrow_forwardIn C++arrow_forwardC++arrow_forward
- 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