How to do memory traces..

So I missed a day of class due to a snowstorm and I have a test coming up on a topic I missed and I cant find any information on it online on how to do it and I'm really stressed, I'm hoping one of you guys can helpe me out.

4. Show exactly the memory trace and the output generated by each of the following (Assume all variables are declared int):



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(a)

x= 10; y=20; z=30;
if (x > 8)
if (y > 8){
cout << "if-1: yes - yes-----" << endl;
cout << "end of if1 yes -- yes\n";
}
else { 
cout << "if-1: yes - no -----" << endl;
cout << "end of if1 yes-no\n"';
}
else cout << "if-1: no\n";

if (y < 15 ||z & 8 ==6){
cout << "if-2: yes -----" << endl;
cout << "end of if2 yes\n";
}
else { 
cout << "if-2: no -----" << endl;
cout << "end of if2 no\n";
}

If (x+y > 40 && x+ z > 40) {
cout << "if-3: yes \n";
else cout << if-3: no \n";
 
Assume all variables are declared int
16-bit int, 32-bit int or 64-bit int?
Show exactly the memory trace
Of the whole program? Or of the shown stack variables? Are optimisation been turned on?

output generated
Did you try to compile and execute that program to see what it does?
Topic archived. No new replies allowed.