Now consider where the next empty slot is in the array you just defined. You can use the numElt variable to access it.
Use it to add an element to that array and increment numElt after the element...
Type: Posts; User: Norm
Now consider where the next empty slot is in the array you just defined. You can use the numElt variable to access it.
Use it to add an element to that array and increment numElt after the element...
Try writing a simple program that defines an array and an int variable: numElt. Add some elements to the array but don't fill it and set the value of numElt to the number of elements that were added...
That is not very efficient to use a loop every time you want to know how many slots are used. Why not have the count of the number of used slots in a variable like: numElt?
If the array has 100 slots and the code is only going to use some of them, how do you keep track of how many slots of the array have been used?
numElt would be an int that has the count of the number of elements in the array that are being used. If the array had 100 elements and there were 5 elements in the array, numElt would be 5
What part of the assignment are you having problems with?