Question: 2. Write a main program that declares and initializes an integer array z of 5 integer elements. Initialize the elements of z array with

2. Write a main program that declares and initializes an integer array z of 5 integer elements. Initialize

2. Write a main program that declares and initializes an integer array z of 5 integer elements. Initialize the elements of z array with some integer values. The program performs the following tasks (in this sequence): a. Declare a pointer p to an integer, and point it to the last element of the array z. b. Print the address of the last element of the array z using the pointer p. c. By incrementing (or decrementing) the pointer p appropriately, and using dereferencing operator, print the contents of z array in the reverse order (i.e., first z[4], then z[3],... z[0]). d. Print the starting address of the array z using the pointer p. e. By incrementing (or decrementing) the pointer p appropriately, print the addresses of all array elements (i.e., addresses of z[0], z[1]...z[4]). Sample Run: Enter five integers> 1 3 7 6 -1 Address of the last element is 0x7ffeefbff490 z[4] = -1 z[3] = 6 z[2] = 7 z[1] = 3 z[0] = 1 Address of the first element is 0x7ffeefbff480 Addresses of all elements: z[0]=0x7ffeefbff480 z[1] = 0x7ffeefbff484 z[2] = 0x7ffeefbff488 z[3] = 0x7ffeefbff48c z[4] = 0x7ffeefbff490

Step by Step Solution

3.45 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include Using na... View full answer

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!