C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
Expert Solution & Answer
Book Icon
Chapter 12, Problem 12SA

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

    int *myPtr = new int;

    int *yourPtr = new int;

    //assign value to the memory location pointed to by myPtr

    *myPtr = 10;

    //assign value to memory location pointed to by myPtr

    //using an arithmetic expression

    //RHS expression = 2 &*#x00A0;10 + 3 = 23

    *yourPtr = 2 &*#x00A0;*myPtr + 3;

    //print statement using arithmetic expression

    //value held in memory location myPtr is 10

    //the second expression = (23 - 10 + 5) = 18

    cout << *myPtr << " " << (*yourPtr - *myPtr + 5) << endl;

    //pointer myPtr assigned the pointer yourPtr so

    //now myPtr refers to the memory location holding

    //the value 23

    myPtr = yourPtr;

  ;&#...

Blurred answer
Students have asked these similar questions
I need help understanding each line of code. Can you please explain each line of code so I can fully understand what is going on step by step? I have experience in c++ so maybe you can also point out some differences between this code and c++ code. Thank you!    #include <stdio.h> int main(void) { char *stringPtr = "Hello world.\n"; while (*stringPtr != '\0') { printf("%p: ", stringPtr); printf("0x%02x\n", *stringPtr); stringPtr++; } printf("%p: ", stringPtr); printf("0x%02x\n", *stringPtr); return 0; }
What is the output of the following C++ code? (2, 3) Submit your answer to dropbox. inti=1; int num=2; while(i<5) { num-num*i; i=i+1; } cout<<"i="<<i<<"and num="<<num<<endl;
I am needing assistance with the following program build in C++.    To make telephone numbers easier to remember, some companies use letters to show their telephone number. For example, using letters, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 225-5466 can be displayed as CALL HOME, which uses eight letters. Write a program that prompts the user to enter a telephone number expressed in letters and outputs the corresponding telephone number in digits. If the user enters more than seven letters, then process only the first seven letters. Also output the – (hyphen) after the third digit. Allow the user to use both uppercase and lowercase letters as well as spaces between words. Moreover, your program should process as many telephone numbers as the user wants.
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