Question: a) Complete the following code segment based on the instructions/comments given in Figure 1 and sample output in Figure 2. [4 Marks] int numl=10, num2=20,

a) Complete the following code segment based on the instructions/comments given in Figure 1 and sample output in Figure 2. [4 Marks] int numl=10, num2=20, array[3] = {2,4,6}; int &num3 = num2; int *ptri, *ptr2; //example : ptrl pointing to num1 Answer : ptrl = &numl; //assign value stored in ptri to ptr2 i) //ptrl pointing to the first element in array ii) //add value pointed to by ptr2 with 3 and store the result in array element index 2, use both pointer ptrl and ptr2 in your answer. iii) //add value pointed to by ptrl with 4 and store in num3 iv) cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
