Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
include Using na...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started