Question

1.when we create a dynamic array the area of memory used is called a. runtime area...

1.when we create a dynamic array the area of memory used is called

a. runtime area

b. usable memory area

c. heap

d. stack

Homework Answers

Answer #1

Kindly cherry-pick up the language applicable (one of C/C++/Java)

The answer to the question is at the end, after explaining the different types of memory-allocations.

Arrays can be declared in three ways :

On the stack, locally in functions :

Following is the common manner of declaring a function-local array, on a stack.

void foo()

{

int arr[] = {123, 53, 21, 89};

}

On the heap, dyamically :

For C :

void foo()

{

int *arr = (int*) malloc(4 * sizeof(int));

arr[0] = 123;

arr[1] = 53;

arr[2] = 21;

arr[3] = 89;

}

For C++ :

void foo()

{

int *arr = new int[4];

arr[0] = 123;

arr[1] = 53;

arr[2] = 21;

arr[3] = 89;

}

For Java :

void foo()

{

int arr[] = new int[4];

arr[0] = 123;

arr[1] = 53;

arr[2] = 21;

arr[3] = 89;

}

All other variables :

Everything else uses the data segment of the process/program.

Thus, the correct option is :

c. heap

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
for c language What function is used to deallocate dynamic memory when it is no longer...
for c language What function is used to deallocate dynamic memory when it is no longer required by your program? In your answer give the name of the function and its syntax, and how the C runtime system knows how much memory to deallocate. Give an appropriate example showing typical usage of this function
suppose you have allocated an array of twenty doubles, called values, on the heap. Write the...
suppose you have allocated an array of twenty doubles, called values, on the heap. Write the line of code (including the semicolon) to free up the memory when the array is no longer needed. c code
In C++, create an array called session1 that has 44 elements (44 students in session1). Each...
In C++, create an array called session1 that has 44 elements (44 students in session1). Each element of the array is an object of Student, where Student is declared as 'struct' with three data members called identification, scores, and grade. Randomly assign grades for each element ranging from [50,100]. MUST USE DYNAMIC ARRAYS.
When we create an array of values and calculate the standard deviation of the array in...
When we create an array of values and calculate the standard deviation of the array in R (using sd() function) and Python (using std() function from NumPy package.), think and give an explanation why the results are different
In C++ 1.) Create a function called copyMyArray. It should take in an array and copy...
In C++ 1.) Create a function called copyMyArray. It should take in an array and copy array1 into array2. 2.) Create a vector and fill it with the numbers 1 to 10. Replace the number 3 with the number 3000. Insert the number 5000 between the 5 and 6.
• First, create a function called addNumber, which has a formal parameter for an array of...
• First, create a function called addNumber, which has a formal parameter for an array of integers and increase the value of each array element by a random integer number between 1 to 10. o Add any other formal parameters that are needed. • Second, create another function called printReverse that prints this array in reverse order. • Then, you need to write a C++ program to test the use of these two functions.
1.Select all C++ functions that must be defined for implementing deep copies in your class which...
1.Select all C++ functions that must be defined for implementing deep copies in your class which has instance variables pointing to dynamic memories. Group of answer choices a.Default Constructor b.Copy Constructor c.Overloading assignment operator d.Writing own friend functions to directly access dynamically allocated memories e.Writing own destructor to free the allocated memory f.Overloading new operator 2. Match the memory source (right side) of the variables (left side) of the following code snippet which is a part of 'myProg' program. Note...
In the following C code, Which variable if NOT of primitive data type? A. a B....
In the following C code, Which variable if NOT of primitive data type? A. a B. b C. c D. d int a = 10; double b = 20.0; float c = false; char d[5] = "Hello"; // here we define a string In programming language C, the implementation of a string data type is limited dynamic length, which means the length of a string variable is fixed once it has been defined. A. True B. False In C# programming...
String array operations a. Create a string array called myInformationcontaining the following entries in order: Your...
String array operations a. Create a string array called myInformationcontaining the following entries in order: Your full name The name of the town or city where you were born Your major The name of this university with only the first letter of each word capitalized; don’t forget the “The”! b. Use the Matlab function strcmp to compare the name of the university as you defined it against the following two strings: i. “The Ohio State University” ii. “THE OHIO STATE...
C++ 1. An array of integers is said to be a palindrome if it is read...
C++ 1. An array of integers is said to be a palindrome if it is read the same from right to left and from left to right such as 1 2 3 2 1. Implement a program that: a. Prompts the user for an integer value n which represents the number of integers to be read next. b. Create a one dimensional dynamic array with size equal to n. c. Create two pointers front and rear and make them point...