# computer science C++

posted by .

The variables arr1 and arr2 have been declared as pointers to integers. An array of 10 elements has been allocated, its pointer assigned to arr1, and the elements initialized to some values. Allocate an array of 20 elements, assign its pointer to arr2, copy the 10 elements from arr1 to the first 10 elements of arr2, and initialize the remander of the elements of arr2 to 0.

Can someone help me get started on this program. This is a question from myprogramminglab..

• computer science C++ -

Don't know you still use pointers in C++, but that's OK.

To declare pointer arr1 to an integer, you would do
int *arr1;

Assuming you have assigned an array called iarray:
int iarray[20];

Assigning the pointer to the beginning of the array is
arr1=iarray; // or
arr1=iarray[0];
Hope that gets you started.

## Similar Questions

1. ### Programming

Here is the source code for the Kitty class: public class Kitty { String name; int age; public Kitty(){ } public void setName(String n){ name = n; } public String getName(){ return name; } public void setAge(int a){ age = a; } public …
2. ### computer science

int *reverse(const int *, int); int *temp; temp = reverse(arr1,N); int *reverse(const int *arr1, int N) { int *arr2; arr2 = new int[N]; for(int count = 0; count < N; count++) { for(int index = (N-1); index <= 0; index--) arr2[count] …
3. ### computer science

The variable cp_arr has been declared as an array of 26 pointers to char. Allocate 26 character values, initialized to the letters 'A' through 'Z' and assign their pointers to the elements of cp_arr (in that order).
4. ### computer science

The variable cp_arr has been declared as an array of 26 pointers to char. Allocate 26 character values, initialized to the letters 'A' through 'Z' and assign their pointers to the elements of cp_arr (in that order). int *arr1[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; …
5. ### computer science

9.10: Reverse Array Write a function that accepts an int array and the array’s size as arguments. The function should create a copy of the array, except that the element values should be reversed in the copy. The function should …
6. ### computer science

Declare a structure whose tag name is Emp and that contains these fields (in the following order): a double field named d, a character pointer named str, and an array of eleven integers named arr. * I'm good till here. In addition, …
7. ### computer science

my code works in c++ so the logical I am getting error must be in the reading of the problem, but I can't see it: Given a type Money that is a structured type with two int fields, dollars and cents. Assume that an array named monthlySales …
8. ### computer science

Assume that BlogComment is a structured type with these fields, comment (a string, the actual comment), and two int fields: like, dislike which count the number of "likes" and "dislikes" of the comment by visitors. Assume that nComments …
9. ### assembler language

write an assembly language subordinate count according to these specs: accepts a pointer to an array or signed words in register X. Accepts a word value in register Y, which indicates the number of array elementsl Returns the number …
10. ### C++

The variables arr1 and arr2 have been declared as pointers to integers . An array of 10 elements has been allocated, its pointer assigned to arr1, and the elements initialized to some values . Allocate an array of 20 elements , assign …

More Similar Questions