THE ANSWER SHOULD TO BE VERY CLEAR .. Use Word to process your homework and subm
ID: 641084 • Letter: T
Question
THE ANSWER SHOULD TO BE VERY CLEAR ..
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. L (55 points) Write a C++ code that includes the following operations: z=x+y z=z/3 x, y, and z are integer variable& A void function (subroutine) named GetData should be declared to get data 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 xFF2AExplanation / Answer
#include <iostream>
using namespace std;
void getData(int *val){
cout << "Enter a value: ";
cin >> *val;
}
int main(){
int x, y, z;
getData(&x);
getData(&y);
z = x + y;
cout << "Value of z = x + y is " << z << endl;
z = z / 3;
cout << "Value of z after z = z/3 is " << z << endl;
return 0;
}
___________________________________________________________________________________________
#include <iostream>
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 << "for t address: " << hex << &t << " and value: " << t << endl;
cout << "for s address: " << hex << &s << " and value: " << s << endl;
cout << "for r address: " << hex << &r << " and value: " << r << endl;
cout << "for q address: " << hex << &q << " and value: " << q << endl;
cout << "for x address: " << hex << &x << " and value: " << x << endl;
cout << "for d address: " << hex << &d << " and value: " << d << endl;
cout << "for c address: " << hex << &c << " and value: " << c << endl;
cout << "for b address: " << hex << &b << " and value: " << b << endl;
cout << "for a address: " << hex << &a << " and value: " << a << endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.