How to define array length based on input

I have problem with array
Input prime number, then input is n
example input : 29
length array is n-1
then define array should be int primeNumber[n-1];

add to that array with prime number 2 until 29
then array will be
primeNumber[28] = {2,3,5,7,11,13,17,19,23,29}

And the last is print array
output is "Prime number is 2 3 5 7 11 19 23 29."
"number of prime number is 8"

Please help me Thank you
You will have to use dynamically allocated memory.

Have a read through this http://www.cplusplus.com/doc/tutorial/dynamic/

Try put some code together & I'll help along the way.

Nick.
Topic archived. No new replies allowed.