Help me trace the output!

Here is the sample code. I was asked to trace it but i can't get everything right. So far I managed to find the output of the line 6th. Is there any easier ways to trace this code besides using a compiler? Sorry for my bad English.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int *pt1, *pt2, *pt3, num;
pt1 = new int(2);
pt2 = new int[5];
num = *pt1;
pt3 = #
cout << *pt1 << " " << *pt3;
cout << endl;

pt3 = pt2;
*pt3 = 4;
pt2++;

for(int i = 0; i < 4; i++)
{
 *pt2 = (*pt1 * i) - *pt3;
 cout << *pt2 << " ";
 pt3++;
 pt2++;
}
cout << endl;
cout << *(pt3 - 2);


-cplusx2
Topic archived. No new replies allowed.