Define fixed heap-dynamic arrays. (b) Write a code snippet (in your favourite language) that creates a fixed heap-dynamic array?
Dynamically allocated memory is allocated on heap and thus heap-dynamic array refers to dynamic arrays .
Dynamic array is an array which doesn't occupies a limited space or memoy.
It is initialised as:
int * arr= new int(n);
CODE IN C++:
#include<iostream>
using namespace std;
int main()
{
int size;//size of array
cout<<"Enter the size of array : ";
cin>>size;
int *arr=new int(size);
cout<<"Enter the array elements : ";
for(int i=0;i<size;i++)
{
cin>>arr[i];
}
cout<<"The array contains : ";
for(int i=0;i<size;i++)
{
cout<<arr[i];
}
}
OUTPUT SNIPPET:
Get Answers For Free
Most questions answered within 1 hours.