EBK C++ PROGRAMMING: FROM PROBLEM ANALY
EBK C++ PROGRAMMING: FROM PROBLEM ANALY
8th Edition
ISBN: 9781337514491
Author: Malik
Publisher: CENGAGE LEARNING - CONSIGNMENT
Expert Solution & Answer
Book Icon
Chapter 12, Problem 9SA

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...

Blurred answer
Students have asked these similar questions
can obtain the remainder of this division by using the % operator. For example, 10 % 3 is 1. In C++, the % can be applied only to integer operands; it cannot be applied to floating-point types. The following program demonstrates the modulus operator:
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?
please can you do that in c++ Sample Testcase 0: Input: 7 8 Output: 40 52 Sample Testcase 1: Input: 7 19 Output: NA 52 Sample Testcase 2: Input: -10 -5 Output: 2 16                       #include <iostream>     #include <cmath>   using namespace std;   ​   int main()     {      int array[1000] = {};      int start = 0;      int numAtIndex  = 0;      cin>>start;      cin>>numAtIndex;   ​      // Your code start here   ​      // Your code end here   ​      return 0;     }
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education