answersLogoWhite

0

wen d values are put in to a packet of array it is easier to use than a bunch of variables.. arrays have its built-in functions which makes its usage easier.

User Avatar

Janiya Hyatt

Lvl 10
4y ago

What else can I help you with?

Continue Learning about Engineering

What is meant by delare or initialize a variable or constant at a lowest possible level?

It probably refers to "scope" (see http://en.wikipedia.org/wiki/Scope_(programming)). In programming languages with lexical scope, variables declared in an outer scope can be used in an inner scope, but variables declared in an inner scope cannot be used in outer scopes. It is considered best practice to declare variables (and constants, which are just variables that don't change) at the innermost scope possible for several reasons: # It makes it most clear what the scope of use is of the variable. # It makes it impossible to mistakenly use it in some other location. # It makes it easier to keep track of what variables exist at any given point in the code. For example, in standard C, nested functions are not allowed. This means that in any function, only two types of variables exist - global variables, and variables declared within that function. This has the advantage of making it easy to understand what any variable refers to.


What is an array for 13?

Ah, arrays are like magical palettes where you can organize and store multiple items in one place. Imagine a lovely garden with 13 different flowers, each in its own spot but all part of the same beautiful landscape. In the world of programming, an array for 13 would be a collection that can hold 13 elements, making it easier to work with and manage those items together. Just like painting a happy little picture, arrays help keep things nice and tidy.


How is memory allocated to arrays?

It depends where the array is declared and whether or not it is fixed-length or variable-length. The only thing all arrays have in common is that the memory is allocated contiguously. Fixed length arrays are arrays where the length is known at compile time while variable length arrays have unknown length and are allocated at runtime. Fixed-length arrays can be allocated statically, on the call stack (local memory) or on the heap (the free store) while variable length arrays must always be allocated on heap. Fixed-length arrays should use a constant variable to refer to the array length consistently while variable-length arrays should use a (mutable) variable. Arrays allocated on the heap must also use a pointer variable to keep track of the start address. The array (or pointer) and its length should always be declared in the same scope. Storing both in a data structure makes it easier to keep track of the array and its length. Static arrays are always fixed length and are allocated at load-time, before entry to the main function (even if declared in the main function or in another function entirely). The memory remains allocated until the program terminates. If there is insufficient memory available, the program itself will fail to load. It is recommended you use static memory sparingly and avoid the use of globals whenever possible. Local arrays are also fixed length but are allocated on the call stack at runtime as and when they come into scope. The memory is released automatically when the array falls from scope. The stack is fixed-length and therefore has limited capacity, so local arrays should be used sparingly. Variable length arrays and fixed-length arrays allocated on the heap are allocated and released manually (programmatically) at runtime. It is the programmer's responsibility to keep track of the array's start address. If there is insufficient memory available, it is the programmer's responsibility to handle the exception. Examples: // Fixed-length array at global scope // Note that all globals are implicitly static: const int a=10; int A[a]; // static array of 10 integers // Fixed-length array at file scope // Note that all file scope variables are explicitly static: static const int b=20; static int B[b]; // static array of 20 integers // Fixed-length arrays at function scope: void f () { const int size=100; static int C[size]; // static array of 100 integers (allocated at load-time) int D[size]; // local array of 100 integers (allocated when f comes into scope) int* E = malloc (size * sizeof (int)); // heap array of 100 integers // Note: if E is NULL, the allocation failed! // ...use arrays... free (E); // release the allocation before E falls from scope! E = NULL; // good housekeeping! } // D is released here // C, D and E will fall from scope here, however C is not released // Variable-length arrays at function scope: void g (const int n) { int* F = malloc (var * sizeof (int)); // heap array of n integers // ...use array... free (F); F = NULL; } // F falls from scope here.


What is Array in Programming C?

Arrays allow similar types of data to be stored within a contiguous block of memory such that every data element is accessible in constant time, regardless of its physical location within the array. This is achieved through simple pointer arithmetic treating each element as a memory offset from the start of the array. Since every element is the same length (in bytes), locating any element is simply a matter of calculating its offset from its index. Indices are zero-based thus the third element can be found at index 2. The memory offset for that element is therefore the product of the element size and 2. However, C permits indices to be specified directly, while the pointer arithmetic is done in the background. Thus array_name[2] automatically returns a reference to the third element. Arrays with large and complex variable length data elements need to store those elements separately from the array, usually non-contiguously. This is achieved by using a pointer array. Pointer arrays are particularly useful when sorting extremely large data lists as it is much easier and more efficient to implement a sorting algorithm with an array than it is with a linked list, particularly when constant-time random-access is essential to the algorithm. The time and effort in building the array is generally more than compensated for by the efficiency of the algorithm. Arrays can also be divided and subdivided to better model the data they represent. For instance, a chessboard might be implemented as a one-dimensional array of 64 elements, however it makes more sense to model the chessboard in a two-dimensional array of 8x8 elements. Although the array is still allocated contiguously and can be thought of as being 8 rows and 8 columns, it's actually better to think of this two-dimensional array as being a one-dimensional array of 8 elements, where each element is another one-dimensional array of 8 elements. By thinking this way it makes it possible to allocate extremely large arrays in non-contiguous memory (as completely separate one-dimensional arrays) and also makes comprehension of a four-dimensional array in a three-dimensional world that much easier (unless you actually want to model time and space of course). A four-dimensional array can be thought of in a variety of ways: as being a one dimensional array of three-dimensional arrays, or as a two-dimensional array of two-dimensional arrays, or as a three-dimensional array of one-dimensional arrays, or even as a one-dimensional array of one-dimensional arrays of one-dimensional arrays of one-dimensional arrays. Whichever method you use to imagine your array is immaterial, so long as it makes sense to you that's all that really matters.


How does a computer understand the password of case sensitive?

Case sensitive passwords are easier to implement than case insensitive, as the program can simply compare each byte of input against each byte of the stored password, and if there are no mismatched bytes, the password matches.

Related Questions

Is it easier to control dependent variables than independent variables in a scientific experiment?

It is easier to control independent variables


What are the advantages of using charts?

It is advantageous to use charts because it makes it easier to compare two variables over a period of time. It also becomes easier to explain or to present certain ideas.


What are the controlled variable of viscosity in a liquid?

The controlled variables for measuring viscosity in a liquid include temperature, pressure, and shear rate. By keeping these variables constant during experiments, it is easier to accurately measure and compare the viscosity of different liquids.


What is the advantage to giving data in percentages?

They are easier to compare.


How can you use proportions to solve equations with variables on both sides?

A calculator can be used to proportions to answer a equation. This is easier to solve when having variables on both sides.


What is the advantage of average?

The advantage of using averages is that they provide a single representative value for a set of data, making it easier to compare different groups or variables. Averages can help simplify complex data sets and identify trends or patterns more easily.


Is it easier to compare percents that it Is fraction why or why not?

Percents are easier since they don't need to be converted. It saves a step.


What is the advantage of giving data as a percentage?

easier to compare bro.


What equations could be the trend line of variables that have a negative correlation?

Easier to reply when full details are given...


What is a direct benefit that consumers enjoy as a result of the internet?

A. It is easier to compare prices.


How does cutting a potato in half help control the variables?

Cutting a potato in half helps control variables by ensuring each half is similar in size and shape, allowing for more consistent cooking or testing conditions. This helps reduce variability in results and makes it easier to compare outcomes.


What the use of line graph?

A line graph can have just one line, or several lines (often using differing colours for clarity). Using several lines make it easier to compare changes that have happened over a period of time.