1. (15 pts) Do both swap_functions work? If not, fix the one(s) that does not work....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. (15 pts) Do both swap_functions work? If not, fix the one(s) that does not work. #include void swap_nums (int *x, int *y) { int tmp; tmp = *x; *x = *y; *y = tmp; } void swap pointers (char *x, char *y) { char *tmp; tmp = x; x = y; y = tmp; } int main() { int a,b; char *s1, *s2; a = 3; b=4; swap_nums (&a, &b); printf("a is %d ", a); printf("b is %d ", b); s1 = "I should print second"; s2 "I should print first"; swap pointers (s1,s2); printf("s1 is %s ", s1); printf("s2 is %s ", s2); return 0; } 1. (15 pts) Do both swap_functions work? If not, fix the one(s) that does not work. #include void swap_nums (int *x, int *y) { int tmp; tmp = *x; *x = *y; *y = tmp; } void swap pointers (char *x, char *y) { char *tmp; tmp = x; x = y; y = tmp; } int main() { int a,b; char *s1, *s2; a = 3; b=4; swap_nums (&a, &b); printf("a is %d ", a); printf("b is %d ", b); s1 = "I should print second"; s2 "I should print first"; swap pointers (s1,s2); printf("s1 is %s ", s1); printf("s2 is %s ", s2); return 0; }
Expert Answer:
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Posted Date:
Students also viewed these programming questions
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
QUIZ... Let D be a poset and let f : D D be a monotone function. (i) Give the definition of the least pre-fixed point, fix (f), of f. Show that fix (f) is a fixed point of f. [5 marks] (ii) Show that...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Suppose there are 50 companies in a commercial building. Initially there is no automatic fire sprinkler system in the public area of the building. Each company has identical individual demand curve...
-
A bar 1 m long is bent and then stress relieved. The radius of curvature to the neutral axis is 0.50 m. The bar is 30 mm thick and is made of an elastic, perfectly plastic material with Y = 600 MPa...
-
Give some very simple rules you might use to manage demand for a firm's product. (An example is "limited to stock on hand.")
-
Costs of information: increasing environmental expenditures. Most major corporations are spending in the tens of millions of dollars annually on environmental costs, with the larger ones spending in...
-
Ariana Peterson recently opened her own law office, which she operates as a corporation. The name of the new entity is Ariana Peterson, Attorney. Peterson experienced the following events during the...
-
The comparative balance sheets of PharoahClothiers are as follows: Cash Accounts receivable Inventory Total assets December 31, 2014 December 31, 2013 $67,200 $45,360 35,840 21,600 51,520 672.000...
-
MBA 708 Essentials of Financial Statement Analysis Week 6 Case Study: Transaction and Financial Analysis Tallulah Company has been in business for several years and is publicly traded on a major U.S....
-
In order to write the Project Introduction, youll need to develop a general sense -- or working knowledge -- of your topic. These days just about everyone accomplishes this with open web searching....
-
What is the probabilistic safety assessment (PSA) and its role in safety assessment of nuclear reactors. Explain the level of maturity achieved by this methodology over the years.
-
Explain the difference between DEC-A and DEC-B?
-
Explain the methodology of evaluating reliability of safety systems.
-
Explain what is a failure mode, failure mechanism, and failure effect in systems.
-
Explain the important outcomes of the three major accidents occurred in nuclear reactors.
-
Use transformations to graph each function. Determine the domain, range, and horizontal asymptote of each function. f(x) = 2 x +1
-
Sportique Boutique reported the following financial data for 2012 and 2011. Instructions(a) Calculate the current ratio for Sportique Boutique for 2012 and 2011.(b) Suppose that at the end of 2012,...
-
Write a method called isVowel that accepts a character as input and returns true if that character is a vowel (a, e, i, o, or u). For an extra challenge, make your method case-insensitive.
-
A List has every method that a Set has, and more. So why would you use a Set rather than a List?
-
Simulate the adding of value 7 to the same heap from the previous problem, after the 21 has already been added. Data from Previous Problem Simulate the adding of the value 21 to the following...
-
A domestic refrigerator consists of (a) A condenser, a compressor and an evaporator (b) A condenser, a throttling valve, a compressor and an evaporator (c) A condenser, a throttling valve and an...
-
The diathermal wall (a) Is incapable of exchanging heat with the surroundings (b) Permits the full flow of heat from the system to the surroundings and vice versa (c) Both (a) and (b) (d) None of...
-
What is the effect of pressure on equilibrium conversion of a gas-phase chemical reaction?
Study smarter with the SolutionInn App