Questions 1: Write an expression that evaluates to 1 more than the value in the
ID: 440126 • Letter: Q
Question
Questions 1: Write an expression that evaluates to 1 more than the value in the location pointed to by the integer pointer variable ip . Thus, if ip points to a location containing the value 3 , the expression should evaluate to 4. ------------------------------------------------------------- Questions 2: 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 remainder of the elements of arr2 to 0. __________________________ for Question 2 this is the code I have so far but still need help: arr2 = new int[20]; for (int i = 0; i < 10 ; i++) { (arr2 + i) = (arr1 + i); } for (int j = 10; j < 20; j++) { *(arr2 + j) = 0; }Explanation / Answer
1> int i = 3
int *pi ;
pi = &i;
(*pi)++;
2> int arr1 = new int[10];
arr1[] = {1,2,3,4,5,6};
int arr2 = new int[20];
for (int i = 0; i < 10 ; i++) {
*(arr2 + i) = *(arr1 + i);
}
for (int j = 10; j < 20; j++) {
*(arr2 + j) = 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.