is it possible?
My professor assigned us work for this week, and it looks like it needs a dynamic array. What we've got to do is have the user enter a range of numbers (say 1-100), and the program calls a method which checks to see if the current number is a prime number, and if it is, puts the number in the prime array.
The problem is, you can't just initialize it to someting like int prime[] = new int[10], because you'll run into problems if the number of prime numbers you end up having is higher than the array length.
This brings me to my need for dynamic arrays. I know you can do them in Visual Basic like this:
Dim intPrime() as Integer
and then use Redim Preserve to make it bigger without losing the data in the array. Unfortunately, our book doesn't discuss this.
I've got class in an hour, so if someone could help, I'd be ever so grateful.
My professor assigned us work for this week, and it looks like it needs a dynamic array. What we've got to do is have the user enter a range of numbers (say 1-100), and the program calls a method which checks to see if the current number is a prime number, and if it is, puts the number in the prime array.
The problem is, you can't just initialize it to someting like int prime[] = new int[10], because you'll run into problems if the number of prime numbers you end up having is higher than the array length.
This brings me to my need for dynamic arrays. I know you can do them in Visual Basic like this:
Dim intPrime() as Integer
and then use Redim Preserve to make it bigger without losing the data in the array. Unfortunately, our book doesn't discuss this.
I've got class in an hour, so if someone could help, I'd be ever so grateful.