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
__ is/are the amount of blank space between lines of text in a paragraph
Natali [406]
Indents? Double Space? one of those
5 0
3 years ago
Read 2 more answers
2) Please create a C program for the following: (25 points) a. Suppose the US dollar to Korean Won is 0.85 dollars to 1000 won.
Zanzabum

Answer:

In C:

#include <stdio.h>

int main(){

       float won,usd,rupee,dinar,peso;

       printf("Won: ");

       scanf("%f", &won);

       usd = won * 0.85/1000;

       rupee = won * 0.85 * 0.14/1000;

       dinar = won * 0.85 * 0.048/1000;

       peso = won * 0.85 * 1.41/1000;

       printf("USD = %f\n", usd);

       printf("Rupee = %f\n", rupee);

       printf("Dinar = %f\n", dinar);

       printf("Peso = %f\n", peso);

   return 0;

}

Explanation:

This declares all variables as float

float won,usd,rupee,dinar,peso;

This prompts the user for Korean Won

       printf("Won: ");

This gets the input for won

       scanf("%f", &won);

This converts to usd

       usd = won * 0.85/1000;

This converts to rupee

       rupee = won * 0.85 * 0.14/1000;

This converts to dinar

       dinar = won * 0.85 * 0.048/1000;

This converts to peso

       peso = won * 0.85 * 1.41/1000;

The next four lines print the converted currencies

       printf("USD = %f\n", usd);

       printf("Rupee = %f\n", rupee);

       printf("Dinar = %f\n", dinar);

       printf("Peso = %f\n", peso);

3 0
3 years ago
Jenny wants to create a résumé after a two-years gap. What should she consider?
gavmur [86]

She should consider jail time.

3 0
4 years ago
Read 2 more answers
You have been instructed to connect a computer to a group of hosts that have been segmented from the regular network. What kind
san4es73 [151]

Answer: VLAN(Virtual local area network)

Explanation: VLAN(Virtual local area network) is the networking device that displays the flexible nature due to the logical connection of one or more LANs. VLAN is used for the purpose of the management, security, scaling etc.

VLAN also has the ability to provide the segmentation in the network by dividing the physical network into segments and making logical network. Router is the source for maintaining the communication in the VLAN.

Thus according to the requirement mentioned in the question ,VLAN is the network device that should be used.

8 0
3 years ago
Tonya is working with a team of subject matter experts to diagnose a problem with her system. The experts determine that the pro
Licemer1 [7]

Answer:

The answer of the following question is Encryption.

Explanation:

Encryption is the second layer of the OSI Layer. It helps reduce the maintenance charges and offload complexity.

Encryption has presents in layer 3 and layer 4 which is IPSec in layer 3 and SSL, TSL in layer 4. of OSI Model.

<u>Note</u>- Only the Encryption can protect the data itself

5 0
3 years ago
Other questions:
  • Solve system of equations. <br>x+2y-z=4<br>2x-y+3z=8 <br>-2x+3y-2z=10
    12·1 answer
  • Which of the following would an interactive media proffessional must likely need
    9·1 answer
  • Which of these jobs would be most appropriate for someone who majors in computer engineering? ANSWER FAST PLEASE
    15·2 answers
  • 1. Caches are important to providing a high-performance memory hierarchy to processors. Below is a list of 32-bit memory address
    7·1 answer
  • Write a program that asks the user for two file names. The first file will be opened for input and the second file will be opene
    8·1 answer
  • Which of the following are tasks you can
    12·2 answers
  • The Daily Trumpet newspaper accepts classified advertisements in 15 categories such as Apartments for Rent and Pets for Sale. De
    9·1 answer
  • 6. According to camp policy, staff members need to be at least 23 years old to transport students. Dean now wants to determine h
    9·1 answer
  • Please help!!!
    9·2 answers
  • Which sentence describe internet safety precautions?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!