Errors in the following code?

What errors are in the following code
1
2
3
4
5
6
7
8
9
int *p, *q;  
 p = new int[5];  
 *p = 2;  for (int i=0; i<5; i++) 
  p[i] = p[i-1] + i;  
 q = p;  
delete[ ] p;  
for (int j=0; j<5; j++) 
  cout<<q[j]<<"  ";  
 cout<<endl;  


I'm doing this for a test review. I'm kinda guessing and saying that it's the p[i - 1] and the delete[]p;
since q = p; you can't cout q if it's deleted.

Is this right? Are there any other errors?
No, there aren't any others.
Topic archived. No new replies allowed.