Find the error in each of the following program segments. Assume int *zPtr; // zPtr will...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Find the error in each of the following program segments. Assume int *zPtr; // zPtr will reference array z int *aPtr NULL; void *sPtr = NULL; int number, i; int z[ 5 ] = { 1, 2, 3, 4, 5 }; sPtr - z; a) ++zptr; b) // use pointer to get first value of array; assume zPtr is initialized number = zPtr; c) // assign array element 2 (the value 3) to number; assume zPtr is initialized number = *zPtr[ 2 ]; d) // print entire array z; assume zPtr is initialized for (i = 0; i < 5; ++i ) { printf( "%d ", zPtr[ i] ); e) // assign the value pointed to by sPtr to number number = *sPtr; f) ++z; Find the error in each of the following program segments. Assume int *zPtr; // zPtr will reference array z int *aPtr NULL; void *sPtr = NULL; int number, i; int z[ 5 ] = { 1, 2, 3, 4, 5 }; sPtr - z; a) ++zptr; b) // use pointer to get first value of array; assume zPtr is initialized number = zPtr; c) // assign array element 2 (the value 3) to number; assume zPtr is initialized number = *zPtr[ 2 ]; d) // print entire array z; assume zPtr is initialized for (i = 0; i < 5; ++i ) { printf( "%d ", zPtr[ i] ); e) // assign the value pointed to by sPtr to number number = *sPtr; f) ++z;
Expert Answer:
Answer rating: 100% (QA)
a Error zPtr has not been initialized Correction Initialize zPtr with zPtr z b Error The pointer is ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Find the error in each of the following program segments. Explain how to correct the error. a) void g() { System.out.println("Inside method g"); void h() { System.out.println("Inside method h"); } }...
-
Find and correct the error in each of the following program segments: a) final int ARRAY_SIZE = 5; ARRAY_SIZE = 10; b) int[] b = new int[10]; for (int i = 0; i
-
Find the error in each of the following code segments, and explain how to correct it: a) i = 1; while (i
-
Most websites have images. There are many different features and functionalities that can be used to work with images via the use of JavaScript. These include preloading, rollovers, and cycling...
-
Multiple Choice Questions a. An auditor most likely would make inquiries of production and sales personnel concerning possible obsolete inventory to address: (1) Valuation. (2) Rights. (3) Existence....
-
Jantzen Companys income statement contained the condensed information below. Jantzens balance sheet contained the comparative data at December 31. Accounts payable pertain to operating expenses....
-
The management of Ercall Limited pays particular attention to the ratios and percentages which they calculate from their annual accounts. For the year ended 31 December 2009, they have calculated the...
-
Ledfords is a chain of home improvement stores. Suppose Ledfords is trying to de-cide whether to produce its own line of Formica countertops, cabinets, and picnic tables. Assume Ledford would incur...
-
A frequency distribution for the response time for EMTS after a 911 cal R
-
On August 1, 2016, Stephanie Ram, a sole proprietor, started a new business, Ram Wholesale Company. The company sells refrigerators (merchandise) to various retail stores and uses the periodic...
-
Which Is Better: To Rent or To Buy? The decision of whether to rent or buy housing is a personal decision that is based on both your lifestyle and your finances. While most financial experts argue...
-
Describe the role of the World Trade Organization (WTO) in international trade. How does the WTO work to resolve trade disputes between member countries?
-
Your opinion on whether or not you think that patients are treated differently based on the type of insurance that they have? Example, are patients that receive Medicaid treated differently than...
-
Analyze how the market structure of monopolistic competition differs from perfect competition and monopoly. Provide examples of industries that fit each market structure.
-
What is the difference between fiscal policy and monetary policy? Describe one tool of each policy and its impact on the national economy.
-
Hypothetically, a television critic writes a reaction piece to the Emmys. In the work, she argues that the winning show should not have received the "Best Drama" accolade. Hypothetically, do you...
-
Snyder Services, Inc. Income Statement Year Ended November 30, 2018 Revenues: Sales revenue Dividend revenue Total revenues $ 237,000 6,000 Expenses: $243,000 Cost of goods sold Salaries expense EA $...
-
Find the work done in pumping all the oil (density S = 50 pounds per cubic foot) over the edge of a cylindrical tank that stands on one of its bases. Assume that the radius of the base is 4 feet, the...
-
Assume that we will use the sample data from Exercise 1 with a 0.05 significance level in a test of the claim that the population mean is greater than 90 sec. If we want to construct a confidence...
-
The Genetics and IVF Institute conducted a clinical trial of the XSORT method designed to increase the probability of conceiving a girl. As of this writing, 945 babies were born to parents using the...
-
Probability of exactly 23 voters use a normal approximation to find the probability of the indicated number of voters. In each case, assume that 100 eligible voters aged 1824 are randomly selected....
-
Define the term measurement.
-
A local magazine makes a listing every year of the places that sell the best pizza in your city. Do you think that a valid measurement system is used to make this list? Why or why not?
-
When you buy a box of cookies in the store, the box usually has information on it containing many different types of measurements about the nutritional content of a serving of cookies. A. What is the...
Study smarter with the SolutionInn App