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
which of the following is the most appropriate way to write css style for the font family property in html
KIM [24]

Answer:

The answer is c your welcome

4 0
2 years ago
A person who wants to buy a compact disc (cd) has just enough money to buy one, and chooses cd a instead of cd
bulgar [2K]

If someone who wants to acquire a compact disc (CD) has just sufficient money to buy one, and chooses CD a instead of CD b, then CD B is the opportunity cost.

 

To add, opportunity cost. <span>the loss of potential gain from other alternatives when one alternative is chosen.</span>

7 0
3 years ago
Read 2 more answers
Calvin needs to design a simple yet professional interface for his users. Which option should he implement?
r-ruslan [8.4K]

Answer:

switchboard

Explanation:

The option that he should implement would be a switchboard interface design. These design structures for graphic user interfaces use a single main page, large icons/buttons, a fixed navigation menu, and all the necessary functionality right in front of the user. This design is made with simplicity in mind in order to make it as easy as possible for a new user to pick up and efficiently and intuitively navigate the user interface. Therefore, since Calvin needs a simple yet professional design, this would be the best implementation.

7 0
2 years ago
Read 2 more answers
Sdq1fdszgdSHTGafeges'
kumpel [21]

Answer:

iooooooooooooooooooooo

Explanation:

ooooooooooooooo

oooo9ooooo9oooooooooo

ooooooooooooooppppooooooooooo

oooooooooooo

ooooooooooooooooooooo

6 0
3 years ago
Programming challenge description: Write a program that, given two binary numbers represented as strings, prints their sum in bi
Lubov Fominskaja [6]

Answer:

The program to this question can be given as:

Program:

#include<iostream>  //include header file

using namespace std;  

string add(string a, string b)  //define add function

{       //declare variable  

   string result = "";  

   int sum = 0,k,l;      

   cahr x;    

   k= a.size() - 1;

   l = b.size() - 1;  

   while (k>= 0 || l>= 0 || sum == 1) //loop

   {

   //addition 

       sum= sum+ ((k >= 0)? a[k] - '0': 0);  

       sum= sum+ ((l >= 0)? b[l] - '0': 0);

        x=sum%2;

      result=(x+'0') +result;

  // Compute carry

       sum =sum/ 2;  

       // Move to next digits  

       k--;  

       l--;  

   }  

   return result; //return value

}

int main()  //main method  

{  

   string a,b;  //string variable

   cout<<"Enter first binary digit: ";  //message.

   cin>>a;     //input from user

   cout<<"Enter Second binary digit: ";  //message.

   cin>>b;     //input from user

   cout <<"Addition :"<<add(a, b)<<endl; //print addition

   return 0;  

}

Output:

Enter first binary digit: 1101

Enter Second binary digit: 100

Addition :10001

Explanation:

In the above c++ program first, we include the header file. Then we define the add function in the add function we add two binary digits by passing value as arguments. In this function, we define a variable that is used on the addition of binary numbers. In this function we define the loop in the loop we check if two binary number is 1 then it will print 0 and pass 1 as the carry. after performing addition it will return value. In the main function, we take two binary numbers from the user and pass the value to the function and print function return value.

8 0
3 years ago
Other questions:
  • Explain what a dam is and what it does
    12·1 answer
  • It's time for you to schedule a dental checkup. The responsible thing to do is to ___
    11·1 answer
  • How can people make sure they are using credit cards responsibly
    14·2 answers
  • In these weeks readings, we learned about the CIA Triad and how each exhibits dependence on the other. Give examples of how fail
    12·1 answer
  • What sends massive amounts of email to a specific person or system that can cause that user's server to stop functioning? mail b
    6·1 answer
  • ________ is a dedicated device designed to manage encrypted connections established over an untrusted network such as the Intern
    12·1 answer
  • The Mail Merge option is located in which tab? a;home b;insert c;refernces d;mailings
    11·2 answers
  • Let's go! About to hit 40k!!! Glad to help on Brainly®!!!
    11·1 answer
  • What will the following program display in the console?
    12·1 answer
  • How to fix a blue screen
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!