2. Write a main program that declares and initializes an integer array z of 5 integer...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Java How To Program Early Objects
ISBN: 9780134743356
11th Edition
Authors: Paul Deitel, Harvey Deitel
Posted Date:
Students also viewed these programming questions
-
In this programming assignment you will practice using ArrayLists, Inheritance and Polymorphism. You are to write a game called Magical Creatures War. You will do this by implementing a class called...
-
Nevada Department Stores is planning to sell its Spring Valley. Fernley, and Winchester stores. The firm expects to sell each of the three stores for the same, positive cash flow of SD. The firm...
-
Jolly Roger Kite Company has a payment cycle of 17 days, a collection cycle of 31 days, and a production cycle of 12 days. What is the average cash conversion cycle for the Jolly Roger Company? A) 60...
-
For the following exercises, find the sum of the infinite geometric series. 46.0.5"-1 n=1
-
An electron moves in a straight line at a speed of \(6.0 \times 10^{7} \mathrm{~m} / \mathrm{s}\). Calculate the magnitude and direction of the magnetic field at a position \(5.0 \mathrm{~mm}\)...
-
You just purchased a bond that matures in 5 years. The bond has a face value of $1,000 and has an 8% annual coupon. The bond has a current yield of 8.21%. What is the bonds yield to maturity?
-
31 (i) Explain why the refractive index of any material with respect to air is always greater 1. (ii) In the figure below a light ray travels from air into the semi-circular plastic block. Give a...
-
You are reviewing audit work papers containing a narrative description of the Tenney Corporations factory payroll sys-tem. A portion of the narrative is as follows: Factory employees punch time clock...
-
A tube bank uses an aligned arrangement of 12-mm diameter tubes with ST = SL = 20 mm. There are 8 rows of tubes with 20 tubes in each row. The tubes are maintained at a surface temperature of 400K,...
-
In the code below, the first printf statement prints out "A[3][5] = 35" What does the second printf statement print out? int main(int argc, char *argv[]) { } int i, j; int A[8][6]; for(i = 0; i <8;...
-
How can leaders proactively manage risks associated with delegation, such as information asymmetry, moral hazard, and delegation aversion, to ensure optimal outcomes and organizational resilience?
-
A zero-coupon bond promises to pay you $10,000 at the end of 20 years. Assuming semi-annual coupon payments, what is the price of the "zero" today if the yield to maturity on the bond is 14 percent...
-
A migrating bird is initially flying south at 12 m/s. To avoid hitting a high-rise building, the bird veers and changes its velocity to 7 m/s east over a period of 2 s. What is the bird's average...
-
What are some situations in which you might experience stress that interferes with your ability to be emotionally available and engaged with others? What are some steps you can take to manage your...
-
Alternative Production Procedures and Operating Leverage Assume Paper Mate is planning to introduce a new executive pen that can be manufactured using either a capital-intensive method or a...
-
The Alert Company is a closely held investment-services group that has been very successful over the past five years, consistently providing most members of the top management group with 50% bonuses....
-
What happens to a local reference in a try block when that block throws an Exception?
-
State whether each of the following is true or false. If false, explain why. a) You must create JavaFX GUIs by hand coding them in Java. b) The layout VBox arranges components vertically in a scene....
-
State whether each of the following is true or false. If false, explain why. a) A thread is not runnable if it has terminated. b) Some operating systems use timeslicing with threads. Therefore, they...
-
In a large office building, there is a woman dead in her locked office, sitting at her desk. Except for the desk, chair, and contents on the desk, the office is empty and the air conditioner is...
-
How many birthdays does the average person have?
-
There are 5 different color houses, occupied by people of 5 different nationalities, who smoke 5 different cigar brands, drink 5 different types of alcohol, and have 5 different pets. The houses are...
Study smarter with the SolutionInn App