+ 2
Your array was defined <size> elements, but you use <n> in your for loops. You need to change the for-loop condition.
for( i = 0; i < size; i++ )
And also the second for-loop
for( i = 1; i < size; i++ )
+ 1
Your "n" variable in the loops has not been initialised.
0
I don't think it's possible to allocate memory for a[size] as well. You have to make this array dynamic by using pointer, and "malloc" in C, or "new" operator in C++, like this:
int * a = malloc(sizeof(int)*size); // C
int * a = new int[size]; // C++
You can use malloc in C++ as well.



