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
MakcuM [25]
4 years ago
11

Write and test a function that takes the addresses of three double variables as arguments and that moves the value of the smalle

st variable into the first variable, the middle value to the second variable, and the largest value into the third value.
Computers and Technology
1 answer:
damaskus [11]4 years ago
7 0

Answer:

#include <bits/stdc++.h>

using namespace std;

// function to swap largest to third, smallest to first and middle to second

void valueSwap(double *a,double *b,double *c)

{

   // variables

  double f,s,t;

 // if value of first is greater than second

  if(*a>=*b)

  {

      // if value of first is greater than third

      if(*a>=*c)

      {

          // swap

          t = *a;

          if(*c>=*b)

          {

              s = *c;

              f = *b;

          }

          else

          {

              //swap

              f = *c;

              s = *b;

          }

      }

      else

      {

          //after all the swap

          f = *b;

          s = *a;

          t = *c;

      }

  }

  else

  {

      // if value of second is greater than third

      if(*b>=*c)

      {

          t = *b;

          if(*c>=*a)

          {

              // swap

              s = *c;

              f = *a;

          }

          else

          {

              //swap

              f = *c;

              s = *a;

          }

      }

      else

      {

          // after all the swap

          t = *c;

          s = *b;

          f = *a;

      }

  }

 

 // final values

  *a = f;

  *b = s;

  *c = t;

 

}

// main function

int main()

{

  // variables

  double n1,n2,n3;

  // ask to enter first number

  cout<<"Enter the first number:";

  // read first number

  cin>>n1;

  // ask to enter second number

  cout<<"Enter the second number:";

  // read second number

  cin>>n2;

  // ask to enter third number

  cout<<"Enter the third number:";

  // read third number

  cin>>n3;

  // call the function to swap values with address parameter

  valueSwap(&n1,&n2,&n3);

  // print number after swapping

  cout<<"Number after swapping: "<<n1<<" "<<n2<<" "<<n3<<endl;

  return 0;

}

Explanation:

Ask user to enter 3 double numbers.Then read 3 numbers from user and assign them  to variables "n1","n2" and "n3" respectively.Call the function valueSwap() which take address of all three variables as argument and then assign the largest value among the three to variable "n3" and smallest to "n1" and middle to variable "n2". Print the values after swapping.

Output:

Enter the first number:20                                                                                                  

Enter the second number:30                                                                                                

Enter the third number:10                                                                                                  

Number after swapping: 10 20 30

You might be interested in
Which of the following is a reason photographing animals can be difficult?
erma4kov [3.2K]
They always move, so its hard catching them still, and if they are in action, you can't get a good picture because it will come out blurry. Hope this helps. Let me know if you need anything else.
4 0
3 years ago
Read 2 more answers
Lesson 3 - Calling All Operators
Tresset [83]

Answer:

.m

Explanation:

3 0
3 years ago
Your team at amazon is overseeing the design of a new high-efficiency data center at hq2. a power grid need to be generated for
elixir [45]

Answer:

void print2(int row) {

for (int i = 0; i < row; i++) {

 char ch = 'a';

 char print = ch;

 for (int j = 0; j <= i; j++) {

  cout << print++;

 }

 cout << endl;

}

}

int count_digits(int num) {

int count = 0;

int temp = num;

while (temp != 0) {

 temp = temp / 10;

 count++;

}

return (num % count);

}

Explanation:

3 0
2 years ago
Which term describes an event where a person who does not have the required clearance or access caveats comes into possession of
notka56 [123]

Answer:

The answer is "compromise"

Explanation:

In computer science, the comprised system is used to describe as any technological resource, that has been negatively affected by an untrustworthy source for nondisclosure, integrity or accessibility either deliberately or inadvertently.

  • In this, the mechanical interaction from the unauthorized source or technological progress can result in compromise.
  • This helps you and the partner to meet each other's interests by taking into consideration both the positions and the solution to the main problem.

4 0
3 years ago
Read 2 more answers
The total number of errors divided by the total number of bits transmitted is the definition of __________. committed informatio
kodGreya [7K]

The answer in the blank is bit error rate, for it is where errors usually occurs and this happens during the digital data transmission. Because of the errors that it is being managed, it divides those errors by the total number of bits that are being transmitted during the process. It happens within a given period.

8 0
4 years ago
Other questions:
  • Respond to the following in a paragraph of no less than 125 words. What is the purpose of netiquette guidelines?
    10·1 answer
  • How do you uninstall a program using the Control Panel?
    10·1 answer
  • Project managers have the overall responsibility for planning, executing, and completing a project. True False
    7·2 answers
  • To run a PHP application that has been deployed on your own computer you can enter a URL in the address bar of your browser that
    7·1 answer
  • Assume a 16-word direct mapped cache with b=1 word is given. Also assume that a program running on a computer with this cache me
    6·1 answer
  • Give an example of a situation in which shears would be the best choice and one in which scissors would suffice.
    14·1 answer
  • CC stand for.....in the email platform?
    12·2 answers
  • How 0x86 processor store 0x12345678 in memory ​
    13·1 answer
  • When would it be most beneficial to package a presentation on a CD? Check all that apply. when sending the file via email for di
    6·2 answers
  • Characteristics of 1st generation​ computers
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!