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

Please attach the code so that I can run and check. 1. (55 points) Write a C++ c

ID: 3871610 • Letter: P

Question

Please attach the code so that I can run and check.

1. (55 points) Write a C++ code that includes the following operations: -z3 x, y and z are integer variables. A void function (subroutine) named GetData should be declared to get data forx 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 beern executed. (All pointers are 4 bytes!) No screenshot is needed.) The first byte of memory below is xFF3A int main0 double a= 32.5, b; int c = 5, d= 4.5, x; double "g, int s, t; s=&x; t = &d; value FF3

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