answersLogoWhite

0


Best Answer

Yes. Using an array when multiple elements need to be created at a time is always a better idea than declaring multiple variables. For ex:

Int i, j, k;

Int[] arr;

I have declared 3 int variables and another array just below it. Here since we are using only 3 variables, we can manage to use them without issues but if the number crosses 5 or even more then definitely using an array is always the best option.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Do you use an array when you only have two or three items to track?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How can you dicribe array?

An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.


What are the main features of arrays. How are arrays used and created?

AnswerWhat is an array: In programming languages, an array is a way of storing several items (such as integers). These items must have the same type (only integers, only strings, ...) because an array can't store different items. Every item in an array has a number so the programmer can get the item by using that number. This number is called the index. In some programming languages, the first item has index 0, the second item has index 1 and so on. But in some languages, the first item has index 1 (and then 2, 3, ...).


A collection of items is a?

set


How can you fix an ArrayIndexOutOfBoundsException in java?

This is very common exception and name of the exception class tells exactly what kind of problem you have. If you would look into stack trace, which should have been generated too you would be able to find exact place where it happened. The problem is that "Array Index Out Of Bounds". This means that you used index on array which is invalid. That could negative number, because all arrays starts from 0. If you array has N items and you will try to get item with index N or higher you will get this exception too. Only available indexes are from 0 to N - 1, where 0 points to the first item and N - 1 to the last one.


When an array contains values other than primitive data types is it considered a control array?

Only if the non-primitive data types are actually controls, such as an array of label controls, or an array of edit boxes. However, a control array is still an array. The only difference is that the values will likely be resource handles (objects that refer or point to the actual object which will be stored elsewhere in memory) rather than an actual value itself. That is, an array of primitive data types stores the actual value in the array itself.

Related questions

How can you dicribe array?

An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.An array is when you store several data items with a single name. You only use a number to distinguish the individual items. Or two or more numbers, if you use a multidimensional array.


What are the main features of arrays. How are arrays used and created?

AnswerWhat is an array: In programming languages, an array is a way of storing several items (such as integers). These items must have the same type (only integers, only strings, ...) because an array can't store different items. Every item in an array has a number so the programmer can get the item by using that number. This number is called the index. In some programming languages, the first item has index 0, the second item has index 1 and so on. But in some languages, the first item has index 1 (and then 2, 3, ...).


How can you find the length of multi dimensional array according to data structure?

There is no way to determine the length of an array in C. All arrays implicitly convert to pointers and a pointer tells you nothing about the number of elements it refers to. The only way to keep track of the number of elements being referred to is to store the length of the allocation at the time the allocation was made. If you fail to store the length, then there is simply no way to calculate it. Note that the length of a fixed-length array is always known to the compiler but only within the scope of the declaration. If we pass a fixed-length array to a function, the array implicitly converts to a pointer and the length can no longer be determined. However, we can use a constant variable to keep track of a fixed-length array's size and pass both the array and its length as separate arguments to a function. For variable-length arrays we must use non-constant variables. A structure helps to encapsulate both pieces of information. For example, the following structure can be used to keep track of integer arrays: typedef struct int_array { int* ptr; // pointer to a variable-length array of type int unsigned size; // the number of elements allocated to the array }; We can also use structures such as this to keep track of how many elements are actually in use. This is useful as it allows us to push values into the array without having to continually re-allocate the array, which is an expensive operation.


Is array is structure or not?

Array is not a struct. Array only has one datatype, struct has arbitrary different datatypes.


What is the difference between Strings and Arrays in c?

There is no difference. A string is just an array of type char. The only real difference is that we do not need to keep track of the length of a string because strings are null-terminated in C. If a string does not have a null-terminator, then it is just an ordinary array of character values.


How does two dimensional array differ from single dimensional array?

A one dimensional array is a scalar value repeated one or more times.A two dimensional array is an array of one dimensional arrays.A three dimensional array is an array of two dimensional arrays, and so forth.The one dimensional array is like a list of things, where the two dimensional array is like an array of things. (Think one row of a spreadsheet versus the whole spreadsheet.)[addendum]Every level of array depth is also a level of pointer depth. For example: A 3 dimensional int array is an int***. So a one dimensional int array is an int*, and a two dimensional int array is an int**. This is only important if you are doing pointer work, but it can become very important.


What is the difference between a numericial array and an associative array?

A numericial array is an array with keys made up of only integers. An associative array is an array with keys made up of anything that is not an integer. In some languages, it is possible to mix integer keys and non-integer keys into a mixed array.


A collection of items is a?

set


How far around a school track is 30 meters?

That's only about three quarters of one straightaway


How can you fix an ArrayIndexOutOfBoundsException in java?

This is very common exception and name of the exception class tells exactly what kind of problem you have. If you would look into stack trace, which should have been generated too you would be able to find exact place where it happened. The problem is that "Array Index Out Of Bounds". This means that you used index on array which is invalid. That could negative number, because all arrays starts from 0. If you array has N items and you will try to get item with index N or higher you will get this exception too. Only available indexes are from 0 to N - 1, where 0 points to the first item and N - 1 to the last one.


When an array contains values other than primitive data types is it considered a control array?

Only if the non-primitive data types are actually controls, such as an array of label controls, or an array of edit boxes. However, a control array is still an array. The only difference is that the values will likely be resource handles (objects that refer or point to the actual object which will be stored elsewhere in memory) rather than an actual value itself. That is, an array of primitive data types stores the actual value in the array itself.


Other than curling what are the only other three winter Olympic sports held indoors?

Speed skating (long track and short track), ice hockey, and figure skating.