congugative memory allocation ,is use to array
Elements of the array.
Simple non-array variables are usually passed to methods by value.
Object array is called universal array because it can store multiple variables of the same type
Full representation of an array begins from the index 0 and ends at n-1 where n is the number of variables of the array.
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.
Elements of the array.
Simple non-array variables are usually passed to methods by value.
Unlike ordinary variables, the variables within an array do not have any names; they are anonymous. To access them you need to use memory offsets from the start of the array. Since the elements of an array are all the same type they are also the same length, thus the offsets are equal to the length of the array type. However, there is no need to calculate the offsets because each element's offset has a zero-based index. Thus the second element can be found at offset index 1.
Object array is called universal array because it can store multiple variables of the same type
Full representation of an array begins from the index 0 and ends at n-1 where n is the number of variables of the array.
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.
For global/static variables: yes.For auto variables: no.
the example of array over charcter variables is char ["string"]
An array is a set of numbers that form some sort of regular arrangement. A linear array is a 1-dimensional array consisting of a row or a column of a set of numbers. A 2-dimensional array is a rectangular arrangement of numbers. And there are arrays with higher dimensions. The elements of an array need not be numbers: they could be variables, functions or expressions. In other words, it's a picture to describe a multiplication problem.
You can use unlimited number of variables for a structure and you can also declare array of structures.
Arrays are important because we often need to work with a collection of variables of the same type and, particularly with large collections, it would be impractical to declare and name each one individually. With an array we don't have to name them because the variables are allocated in contiguous memory addresses and every element is the same length. Knowing only the start address of the array and the zero-based index of an element we gain constant-time random access to any element in the array. An array is really just an extension of a type. When we declare a variable of a given type we allocate sufficient memory to hold just one object of that type. With an array, we can allocate as many objects as we require.
If the two arrays are a simple division of the larger array (such as splitting it in half), you can use pointers to mark the start address of each sub-array: int a[10]; int* p1 = &a[0]; // point to first half int* p2 = &a[5]; // point to second half You should also use unsigned integer variables to keep track of the size of each sub-array: unsigned p1size = 5, p2size=5; It's usually best to use a structure to keep array pointers and size variables together in one place: typedef struct intarray { int* ptr; unsigned size; } If you need to split the array in a non-contiguous manner you will need to create new arrays that are at least as large as the original array, and then copy the appropriate elements to the appropriate sub-array. Once copied, you can (optionally) shrink the sub-arrays to eliminate any unused elements.