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

Directly copy the source code and paste into the Word file. Screenshot of runnin

ID: 3871341 • Letter: D

Question

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: z=x+y 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. : (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 main double a- 32.5, b; int c = 5, d = 4.5, x; double *q, r int *s, *t q = &a; s=&x; t = &d; *r = c%d; *s = *t + c;

Explanation / Answer

1. Source Code:


#include <iostream>
#include <string>
using namespace std;
void GetData()
{
int x,y;
float z;
cout<<"Enter The value of the x ";
cin>>x;
cout<<" Enter the value of the y ";
cin>>y;
int *p,*q;
p=&x;
q=&y;
z=*p+*q;
z=z/3;
cout<<" The value of the z is "<<z;
}
int main()
{
GetData();
}

Output:

Enter The value of the x 3

Enter the value of the y 5

The value of the z is 2.66667

2. Source Code:


#include <iostream>
#include <string>
using namespace std;

int main()
{
double a=32.5,b;
int c=5,d=4.5,x;
double *q,*r;
int *s,*t;
q=&a;
r=&b;
s=&x;
t=&d;
*r=c%d;
*s=*t+c;

cout<<"The value of s "<<*s<<" Address is "<<&s;

cout<<" The value of r "<<*r<<" Address is "<<&r;

cout<<" The value of q "<<*q<<" Address is "<<&q;


cout<<" The value of x "<<x<<" Address is "<<&x;

cout<<" The value of d "<<d<<" Address is "<<&d;

cout<<" The value of c "<<c<<" Address is "<<&c;

cout<<" The value of b "<<b<<" Address is "<<&b;

cout<<" The value of a "<<a<<" Address is "<<&a;
}

Output:

The value of s 9 Address is 0x77f6a195c388

The value of r 1 Address is 0x77f6a195c380 T

he value of q 32.5 Address is 0x77f6a195c378

The value of x 9 Address is 0x77f6a195c364

The value of d 4 Address is 0x77f6a195c360

The value of c 5 Address is 0x77f6a195c35c

The value of b 1 Address is 0x77f6a195c370

The value of a 32.5 Address is 0x77f6a195c368

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote