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
How many generations of computer languages
vichka [17]
5 generations................
6 0
3 years ago
A ________ describes the data and relationships that will be stored in a database.
nevsk [136]
Your missing word is Data model.
8 0
3 years ago
A frameset should only be used with XHTML true or false
Naddik [55]
Framesets require a special DTD. If you're writing XHTML and want to use the strict DTD, you can't use frames/framesets.
4 0
3 years ago
True or false :User intent refers to what the user was trying to accomplish by issuing the query
shepuryov [24]

Answer:

answer: User intent is a major factor in search engine optimisation and conversation optimisation. Most of them talk about customer intent ,however is focussed on SEO not CRO

Explanation:

hope we can be friends

can i please get brainliest

3 0
3 years ago
Why must programs written in a high level language be translated into machine language before they can run?
earnstyle [38]
Because machine (cpu) can only execute machine code(language).
5 0
4 years ago
Other questions:
  • The following declaration appears in a program: short totalPay, basePay = 500, bonus = 1000; The following statement appears in
    9·1 answer
  • In addition to talking to other doctors remotely, telegraphy technology?
    5·1 answer
  • What does nat stand for? network access trigger network administration timetable network address translation network association
    13·1 answer
  • You knew that you had to take this quiz so you logged into Blackboard and went to the quizzes section. In this scenario your com
    11·1 answer
  • There are _______ pints are in 8 cups.
    10·2 answers
  • If you are working with a team of students on a class project and your team chooses to share content by uploading Word and Excel
    13·1 answer
  • How are logical operators used?
    14·1 answer
  • The premise of this exam is to synthesize your knowledge and understanding of recursion. Your synthesize may be in the form of a
    14·1 answer
  • In the context of applications of artificial intelligence (AI), _____ perform well at simple, repetitive tasks and can be used t
    11·1 answer
  • Please help! In your own words explain the difference between a problem and an algorithm.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!