Question: Exercise 2 : Some errors in the use of pointers Find the error in each of the following program segments and give a corrected version.

Exercise 2: Some errors in the use of pointers
Find the error in each of the following program segments and give a corrected version. Given the following declarations
and statements.
int *xPtr; // xPtr will reference array z
int number;
int z[6]={1,2,3,4,5,6};
(a)// Assign the address of z[0] in xPtr
++xPtr
(b)// use pointer to get second value of array z
number = xPtr
(c)// assign the fifth element of the array z
number =*xPtr;
(d)//print the entire array z
int i;
for(i =0;i <=6; i++) printf("%d
", xPtr[i]);
1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!