Assume that group1 and group2 are both of type pointers-to -int. Assume that group1 points to an array of 6 initialized elements. Write some code that allocates a block of 14 integers and assign the address of that allocated memory to group2. Copy the values of the array elements pointed to by group1 to the first 6 elements of the new array that group2 points to. Then initialize the rest of the elements (in the newly allocated array) to 3.
.
.
Click on the title for the solution
.
.
group2 = new int [14];
for(int a=0; a<6; a++)
{
group2[a] = group1[a];
}
for(int a=6; a<14; a++)
{
group2[a] = 3;
}
.
Click on the title for the solution
.
.
This is the answer:
:
group2 = new int [14];
for(int a=0; a<6; a++)
{
group2[a] = group1[a];
}
for(int a=6; a<14; a++)
{
group2[a] = 3;
}
Comments
Post a Comment