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...
-
Assume that a material with a uniaxial yield stress Y yields under a stress state of principal stresses 1, 2, 3, where 1 > 2 > 3, Show that the superposition of a hydrostatic stress, p, on this...
-
The following information is available for Remmers Corporation for 2022. 1. Depreciation reported on the tax return exceeded depreciation reported on the income statement by $120,000. This difference...
-
Almetals, Inc., a Michigan company, entered into a contract with the German firm Wickeder Westfalenstahl regarding the purchase of clad metal, a specialty metal used in a variety of industries but...
-
A manufacturer is considering alternatives for building new plants, to be located closer to three of its primary customers with whom it intends to develop long-term, sole-supplier relationships. The...
-
According to the Civil Code of the Philippines, Article 1 7 6 7 defines partnership as: By the contract of partnership two or more persons bind themselves to contribute money, property, or industry...
-
Compare and contrast the leadership styles exhibited by Steve Jobs and Tim Cook.
-
Cases that raise substantial amount of interest in the use of "advanced directives" which allow individuals to put in writing their wishes regarding incapacitation or authorizing a proxy to make...
-
Over what ranges of taxable income in 2017 will the total income tax liability for two persons with equal incomes who file as single individuals equal their income tax liability if they file jointly...
-
The title of an article in The Wall Street Journal was Pricing of Products Is Still an Art, Often Having Little Link to Costs. In the article, the following cases were cited: Vodka pricing: All...
-
The International Labor Organization estimates that 250 million children in developing countries between the ages of 5 and 14 are working either full- or part-time. The estimate of the percentage of...
-
If you have GPU hardware available, complete a performance analysis your program, examining the computation time for the GPU and a CPU version of your program for a range of vector sizes. Explain any...
-
In 1993 Congress passed the Family and Medical Leave Act (FMLA), which requires firms with more than 50 employees to grant a 12-week unpaid leave of absence for family and medical reasons. What is...
-
In your opinion what are the challenges leaders may experience when managing a healthcare team? What are the leader's responsibilities to the team, specifically related to human resources? How...
-
The manager for retail customers, Katie White, wants to hear your opinion regarding one business offer she has received from an entrepreneur who is starting a mobile phone app called Easy Money. The...
-
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...
-
Professor Ray C. Fair's voting model was introduced in Exercise 2.23. He builds models that explain and predict the U.S. presidential elections. See his website at...
-
In the STAR experiment (Section 7.5.3), children were randomly assigned within schools into three types of classes: small classes with 13-17 students, regular-sized classes with 22-25 students, and...
-
Many cities in California have passed Inclusionary Zoning policies (also known as below-market housing mandates) as an attempt to make housing more affordable. These policies require developers to...
Study smarter with the SolutionInn App