English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

an integer input will be stored in an array. how will i know the number of elements or digits?

2006-08-04 22:15:46 · 4 answers · asked by heaven_cent29 2 in Computers & Internet Programming & Design

visual basic program
hope you could give me an example

2006-08-04 22:55:35 · update #1

4 answers

you should keep track of how many all the time so you know where to add the next element, but in some cases you cant, so you need to set up a loop to count the number of elements. you dont say what language, but heres some pseudocode:

count = 0
while myarray[count] is not equal to NULL
increment count
count now has the number of elements in the array

2006-08-05 02:51:51 · answer #1 · answered by justme 7 · 0 0

From the nature of your problem I assume that u are using a dynamic array.

These steps should work, though I have not tested them.

len(str())

See, if this works. Or, the best way will be to Set a counter which will increment every time you add a new element to the array. At any time, the value of the counter will indicate the no. of elements in your Array.

2006-08-05 00:04:28 · answer #2 · answered by ccsCoder 3 · 0 0

ur question is not clear. use length property for java, ubound for vb.

2006-08-04 22:22:01 · answer #3 · answered by itsme 1 · 0 0

You can run do... Loop.

2006-08-04 22:21:44 · answer #4 · answered by bhaveshiam 1 · 0 0

fedest.com, questions and answers