Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

i-V\'0TQ, @.:|Find Heading 1 Arial Use Word to process your homework and submit

ID: 3869758 • Letter: I

Question

i-V'0TQ, @.:|Find Heading 1 Arial Use Word to process your homework and submit to Blackboard is mandatory Directly copy the source code and paste into the Word file. Screenshot of running result must be presented if applicable. 1. (55 points) Write a C++ code that includes the following operations x, y, and z are integer variables. A void function (subroutine) named GetData should be declared to get data for x and y from keyboard. Hint: Pointers must be used in the subroutine. 2. (45 points) Show the hex addresses and variable values after the statements have been executed. (All pointers are 4 bytes!) (No screenshot is needed.) The first byte of memory below is xFF3A. int mainO double a= 32.5, b; int c 5, d 4.5, x; double *q, T int *s, *t; q &a; r = &b; s=&x; t=&d; *t = c%d; sc; value address xFF3A

Explanation / Answer

1.

#include <iostream>

using namespace std;

void getData(int *ptrx,int *ptry,int*ptrz) //function arguments are pointers to integers

{

  

cout<<"Enter the values of x and y : ";

cin>>*ptrx>>*ptry;

  

*ptrz = *ptrx+*ptry; // the pointers to integers are used in arithmetic expressions

*ptrz = *ptrz/3;

  

  

}

int main() {

int x,y,z;

getData(&x,&y,&z); //function call

cout<<" z = "<<z; //display the value of z after executing function

return 0;

}

Output:

2.

*r = c%d = 5% 4 = 1 = b

*s = *t +c = 4+ 5 = 9 = x

All pointers are of 4 bytes

xFF3A + 4 = xFF3E

and so on

t s r q x d c b a value &d &x &b &a 9 4 5 1.0 32.5 address xFF3A xFF3E xFF42 xFF46 xFF4A xFF4E xFF52 xFF56 xFF5A