Find the error in the following code and explain why? int x = 99; const int*...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Find the error in the following code and explain why? int x = 99; const int* p = &x; const int* p2; int* const pc2; int y = *p; *p2 = 5; p2 = p; P = &y; P = p + 1; int *p3= p; int const p4 = p; const int const p5 = p; int *z p5; 6. Question 6: Write a function that takes a pointer that points to an int array as param, and it makes that pointer point to the first zero. For example: int array [] = {8,5,3,9,3,0,3,1,0,4,8); int *p = array; pointsToFirstZeor (p) ; cout << *p; //0 cout << * (p + 1); //3 cout < (p + 2); //1 Find the error in the following code and explain why? int x = 99; const int* p = &x; const int* p2; int* const pc2; int y = *p; *p2 = 5; p2 = p; P = &y; P = p + 1; int *p3= p; int const p4 = p; const int const p5 = p; int *z p5; 6. Question 6: Write a function that takes a pointer that points to an int array as param, and it makes that pointer point to the first zero. For example: int array [] = {8,5,3,9,3,0,3,1,0,4,8); int *p = array; pointsToFirstZeor (p) ; cout << *p; //0 cout << * (p + 1); //3 cout < (p + 2); //1
Expert Answer:
Answer rating: 100% (QA)
The image you have provided contains a snippet of C code with several declarations and operations involving pointers and youve asked to find an error ... View the full answer
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
Lump Sum Problem: Plugin Amounts for each given variable to receive partial credit, in case your answer is incorrect. Determine how much $2,000 deposited in a savings account paying 12%compounded...
-
Count Dracula, the most famous vampire, rumored to have killed at least 200,000 people, was based on a real person who lived in eastern Europe about 600 years ago. He was indeed a "monster," although...
-
The CDIC (Canadian Deposit Insurance Corporation) insures bank deposits. If a bank's assets are insufficient to pay off all depositors, the CDIC will contribute enough money to ensure that all...
-
Krunkel Company makes two products and uses a traditional costing system in which a single plantwide predetermined overhead rate is computed based on direct labour-hours. Data for the two products...
-
Consider the National Football League data in Table B.1. a. Fit a multiple linear regression model relating the number of games won to the team's passing yardage $\left(x_{2} ight)$, the percentage...
-
Rank the following securities from lowest (1) to highest (8) in terms of their riskiness for an investor. All securities (except the Treasury bond) are for a given firm. If you think two or more...
-
Poster instructions: Tools: You can use a poster board or PowerPoint slide. Assignment: Find 3 pictures that illustrate your values. Find 2 pictures that illustrate how you perceive your workplace...
-
Unpolarized light is incident in air on the flat surface of a sheet of glass of index 1.60 at an angle of 30.0 to the normal. Determine both amplitude coefficients of reflection. What is the...
-
A. Find the probability that a cookie will have 26 chocolate chips, then find the expected number of cookies with 26 chocolate chips among 34 different Keebler cookies. b. Find the probability that a...
-
What is an inverse relationship? How does it graph? What is a direct relationship? How does it graph?
-
If the diameter of a tubular bowl centrifuge is doubled what will be the increase in through put.
-
John Stantus, single, is the sole owner of Stantus Accounting Services, Co. He started the company, which is organized as a sole proprietorship, on February 10 of the current year. For this year,...
-
What is a data mart and why do some organizations use it to support organizational decision making?
-
Andrew Poist works for a public accounting firm in Melbourne, Australia. On 4 October 20XI Sydney Langston, who started selling decorative, carved, wooden ducks out of a booth at Cypress Court...
-
The following data is provided for Garcon Company and Pepper Company. Garcon Pepper Company Company $ 14,200 $ 16,600 14,800 20,250 Beginning finished goods inventory Beginning work in process...
-
A handrail, which weighs 120 N and is 1.8 m long. was mounted to a wall adjacent to a small set of steps (Figure P4.26). The support at A has broken, and the rail has fallen about the loose bolt at 8...
-
A recipe for roasted red-pepper pasta calls for 4 red bell peppers and 5 black olives. Calculate the given unit ratio. What does your result mean in this situation? a. The unit ratio of the number of...
-
A random selection of 969 married adults were asked about their level of happiness. Table 21 compares their responses and their genders. a. Find the probability that a person randomly selected from...
-
Let x be the mean (in points) of three test scores, x1, x2, and x3, all in points. a. Find a formula for the mean of the test scores. b. If a student has test scores of 72 and 85, find the score she...
-
Crane l uses 10 kJ of energy to lift a 50 kg box to the roof of a building. Crane 2 uses 20 kl to lift a 100 kg box the same distance. Which crane is more efficient? A. Crane 1 B. Crane 2 C. Both...
-
A glassblower heats up a blob of glass in a furnace, increasing its temperature by \(1000^{\circ} \mathrm{C}\). By how many kelvins does its temperature increase?
-
Which of the following changes would allow your refrigerator to use less energy to run? (There may be more than one correct answer.) A. Increasing the temperature inside the refrigerator B....
Study smarter with the SolutionInn App