1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Harman [31]
3 years ago
8

Assume that a function named swapdoubles has been defined and is available for use in this exercise: that function receives two

variables of type double and exchanges their values. Write the definition of a function named sort3 that is passed three double variables. The function returns nothing but modifies the values of these variables so they are in sorted order. So, if a, b and c have (respectively) the values 3.14, 2.71, and 3.04, and the invocation sort3(a,b,c) is made, then upon return, the values of a, b and c will be 2.71, 3.04, and 3.14 respectively.
Computers and Technology
1 answer:
Nata [24]3 years ago
6 0

Answer:

C++ Code:

void sort3(double &a, double &b, double &c)

{

   if(a > b)

       swapdoubles(a,b);

   if (b > c)

       swapdoubles(b,c);

   if (a > b)

       swapdoubles(a,b);

}

Explanation:

To change the values of a,b,c within the function, we pass the values by reference. Let us assume that number a = 3.14, b = 2.71, c = 3.04. Since a > b, values of a and b will be swapped.Now a = 2.71 and b = 3.14. Similariy, since b > c, they will be swapped. This way, we move the largest number to its correct position in the first two steps. If there are only three numbers, and the largest number is in its correct position, then for the two remaining numbers, we will only need atmost one swap to exchange their positions. hence, we perform a comparison of a > b once again to see if the b is smaller than a. if its not, then all a,b,c are in sorted order.

You might be interested in
A website for a certain political party or candidate is likely to have unbiased
bagirrra123 [75]
False I believe probably false
4 0
2 years ago
An alteration threat violates information integrity. <br> a. True <br> b. False
Art [367]
The answer is True


It intentionally or unintentionally compromises a system by making unauthorized changes to data. As compared to intentional changes which are usually malicious, unintentional changes are normally accidental. Changes and modifications to the system configurations can also compromise integrity. Such modifications might include deleting, changing, and creating information in a network resource. It is best to implement mechanisms on how one can track and audit such changes as they happen




6 0
3 years ago
Ew<br>subject: Computer<br>11101÷101<br> binary operations<br>​
lions [1.4K]
11101 / 101 = 109.9
5 0
2 years ago
What was software for modems that connected through phone lines called?
balandron [24]

Answer:

Best Regards to all of the people who have met you in the class

4 0
3 years ago
Definition of laptop
zaharov [31]
A device that sucks bc mien broke
7 0
2 years ago
Read 2 more answers
Other questions:
  • The network ____, the person overseeing network operations, uses a server operating system to add and remove users, computers, a
    15·1 answer
  • 1. Write a bash script to create 3 files of different size greater than 1700 kb and less than 1800 kb . The 2. Content of the fi
    9·1 answer
  • In a paragraph of no less than 125 words, describe how technology helps business professionals to be more efficient. Include exa
    12·2 answers
  • Which best describes the differences between a resume and a CV?
    13·2 answers
  • What’s the best description of an opportunity cost
    5·1 answer
  • Write a java program that prompts the user to input the elapsed time for an event in hours, minutes, and seconds. The program th
    13·1 answer
  • The theory of logic set the foundation for what aspect of computing today?
    11·1 answer
  • How do you create a formula in excel​
    10·1 answer
  • fun fact about London(me): when it comes to relationships she becomes clingy to the person shes dating
    10·1 answer
  • You’ve found the file you’ll be working with. Next, you decide to move
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!