Explanation of Solution
The program execution is explained in the in-lined comments:
#include <iostream>
using namespace std;
int main()
{
//declare variables dec1, dec2 and initialize
double dec1 = 2.5;
double dec2 = 3.8;
//declare double pointers p and q
double *p, *q;
//assign the address of variable dec1 to p
p = &dec1;
//assign the value of dec2 - dec1 to the memory
//location pointed to by p which is dec1
//so dec1 now holds the value (3.8-2.5 =) 1.3
*p = dec2 - dec1;
//q is assigned the value of p so both the pointers
//now point to variable dec1
q = p;
//content of the memory location pointed to by q
//is assigned 10.00 so dec1 holds the value 10.0
*q = 10.0;
//the contents of the memory location pointed to by p
//i.e dec1 is assigned the value of the RHS expression
//RHS = 2 &*#x00A0;10 + 10...
Want to see the full answer?
Check out a sample textbook solutionChapter 12 Solutions
EP MINDTAPV2.0 FOR MALIK'S C++ PROGRAMM
- write code in c++ pleasearrow_forwardQ9/Write a program in c++ that inputs a three-digit integer, separates the integer into its individual digits and prints the digits separated from one another by three spaces each by using functions. For example, if the user types in 429, the program should print: 4 2 9arrow_forwardIn c++arrow_forward
- Question 1 Write a program in C which continuously takes integer inputs from the user with Sample Run $/question1 Enter a number: 3 Enter a number: 7 scanf function. By using signal() system call for SIGINT, alter the behaviour of Ctrl-C Inputs: 2, Average: 5 such that whenever the combination is Enter a number: 4 Enter a number: 12 Enter a number: 14 pressed, the program responds with the number of inputs and their average value Inputs: 5, Average: 8 on screen. Use -1 to exit.arrow_forwardAsaparrow_forwardComplete the C++ function given below: int evenDigits(int n){//returns the number of even digits in n}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