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
C++ Programming: From Problem Analysis to Program Design
- int f(int &k){k++;return k * 2;}int main(){int i = 1, j = -1;int a, b, c;a = f(i) + i/2;b = j + f(j) + f(j);c = 2 * f(j);return 0;} What are the values of a, b and c id the operands in the expressions are evaluated from left to right and then what are the values when its evaluated right to left?arrow_forwardC++arrow_forward.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