answersLogoWhite

0


Best Answer

It is an initialisation. You cannot assign values to a dynamic array until it has been initialised. Static arrays can be initialised at compile time. They can also be assigned at compile time.

void main()

{

// Compile time:

// =========

// Initialise a static array.

int arr1[10];

// Initialise and assign a static array.

int arr2[10] = {0,1,2,3,4,5,6,7,8,9};

// Runtime:

// ======

// Dynamic array (size unknown, no memory allocated)

int* pArr[];

// Initialise (size known, allocate memory, 40 bytes):

pArr = ( int* ) malloc( 10 * sizeof( int ));

// Assign (set values of elements):

int x;

for(x=0;x<10;++x)

pArr[x] = x;

// Uninitialise (release memory).

free( pArr );

return( 0 );

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Is run time initialization of an array an initialization or an assignment?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are the advantages and disadvantages of arrays in c sharp?

Advantages: 1. Can store "n" number of same data types in different indexes 2. Can be accesses using reference. Disadvantage: 1. No boundary check, if the array boundary is crossed run time 2. No facility to increase the size of array in Run time


How can you search an array element in a file?

Logic to search element in array Input size and elements in array from user. ... Input number to search from user in some variable say toSearch . Define a flag variable as found = 0 . ... Run loop from 0 to size . ... Inside loop check if current array element is equal to searched number or not. To learn more about data science please visit- Learnbay.co


How do you declare variables during run-time in java?

by the use of constructor . we can initialize the variables in java.The name of the constructor should be same as the name of the class .


What is the term given to the memory allocation that takes place during run time rendering the resizing of an Array?

A reallocation. Note that whenever we reallocate an array, we increase the size of the current allocation if there is sufficient free memory beyond the current allocation or we allocate entirely new memory if there isn't. But when we reduce the size of an array, we simply release the redundant memory at the end of the array; we never allocate new memory. However, because the amount of memory being allocated has to either increase or reduce in size, both are termed a reallocation.


Why should a function that accepts an array as an argument and processes that array also accept an argument specifying the array?

Basically in c++ passing an array as an argument only provides a pointer to the first value and that function won't know how many values it has.If you read beyond the size you will just get garbage from memory.

Related questions

Can you change the base address of an array during run time?

If the compiler allocated the array at compile time, or if the array was automatically allocated as a local variable, then no, you cannot change its base address at run time. If you allocated the array at run time from the heap, you can change its base address by allocating a new array, copying the old elements from old to new and deleting the old array.


How do you access last index of an array if the size is set during run time?

For an array of length s, the last element has index s-1.


Where are array of functions used?

Function Pointers are basically used when we want to select a function which is to be used dynamically at run time.


The procedure entry point security initialization qqrv could not be located in the dynamic link library ntrtl60bpl?

For my case which I can not explain though, Changing run time package will fix this problem Terry G.


What are the advantages and disadvantages of arrays in c sharp?

Advantages: 1. Can store "n" number of same data types in different indexes 2. Can be accesses using reference. Disadvantage: 1. No boundary check, if the array boundary is crossed run time 2. No facility to increase the size of array in Run time


What are Run time errors in java?

sometimes a program in java may compile properly creating a .class file but but may not run properly .The program may produce rong results ue to some wrong logics etc.such errors ocuring at the tiome of runnning are known as run time errors.some of the run time erros are :*(a)dividing an integer by zero.*(b)accesing an element that is out of the bounds of an array.*(c)attemping to use negatie size of an array.*(d)converting invalid strng to a number.


How can you differentiate a lower level array from the higher level array?

Lower level array: 1. Lower level array could be a single dimensional array . 2. It is easy to work with the lower level array . 3. By using lower level array , works get easier. 4. if user try for dry run , he/she can do it without any complication. Higher level array: 1. Higher level array could be a double dimensional array , three dimensional array or nth dimensional array. 2. It's quite complicated to work with higher dimensional arrays. 3. By using higher level array , works get much more easier as compared to lower level array. 4. if user try for dry run , he/she may/maynot do it because there is lot of complications in it.


What are the design issue for array?

What is its size? How is its size determined and when (compile/run-time). What does the software using the array do when the array is empty? partially full? full? Avoid the software addressing elements of the array which are undefined, or addressing elements outside the bounds of the array When and who is responsible for allocating and freeing memory when the array is no longer needed (program or called procedure start/termination) or some other time determined during program execution. If the array is implementing a data structure such as a stack, queue, dequeue, list, etc. What is its implementation of the usual data structure operations, Create, Empty, List Items, Top, First, Last, Next, etc.


How do you create a .Net array bigger than 2 GB?

Run in x64 mode.


How can you search an array element in a file?

Logic to search element in array Input size and elements in array from user. ... Input number to search from user in some variable say toSearch . Define a flag variable as found = 0 . ... Run loop from 0 to size . ... Inside loop check if current array element is equal to searched number or not. To learn more about data science please visit- Learnbay.co


How do you declare variables during run-time in java?

by the use of constructor . we can initialize the variables in java.The name of the constructor should be same as the name of the class .


What is the term given to the memory allocation that takes place during run time rendering the resizing of an Array?

A reallocation. Note that whenever we reallocate an array, we increase the size of the current allocation if there is sufficient free memory beyond the current allocation or we allocate entirely new memory if there isn't. But when we reduce the size of an array, we simply release the redundant memory at the end of the array; we never allocate new memory. However, because the amount of memory being allocated has to either increase or reduce in size, both are termed a reallocation.