0
Int a[n] Is this correct for declearing an array?
after this we can initialize n=5 so then int a[5] is this correct?
4 Answers
+ 4
Correct. But you need define and initialize 'n' variable before using that in as a[n].
int n=5; int a[n]; is correct.
but
int a[n], n=5; is not correct in c..
+ 3
No....because Array size needs to be known at compile time cause it allcates memory statically... So it should be a constant... Like a[10].... When u write a[n].. That n has a garbage value at compile time so it's wrong way cause it allocates array of size n which has garbage value at compile time...cause u are giving value to n later ie at runtime
0
please get me the answer with correct way and with details