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
8_murik_8 [283]
3 years ago
10

(1) Precursor to Array ...a Sorting Program: Write a modular program with a function named sort that takes three integer paramet

ers by reference. The function should rearrange the parameter values so that the first parameter gets set to the largest value, the second parameter gets set to the second largest value, and the third parameter gets set to the smallest value. For example, let's say in the main function we are given the variable assignments num1 = 20; num2 = 10; num3 = 30; then the function call sort(num1,num2,num3) should result in the following changes to the variables in the main function: num1 = 30, num2 = 20, and num3 = 10. Note that although the array construct covered in Chapter 7-8 supports a way to solve this type of problem for an arbitrary number of items instead of only for three items, DO NOT use an array for this programming challenge.
Computers and Technology
1 answer:
olga2289 [7]3 years ago
8 0

Here is code in C++.

#include <bits/stdc++.h>

// include header

using namespace std;

// function to rearrangement the numbers

void Sort(int& i, int& j, int& k)

// values are passed by reference

{

 // first parameter gets largest value

   if(i<j){

       // swap the value of i & j

       int tmp = i;

       i = j;

       j = tmp;

   }

   //second parameter gets second largest value

   if(i<k){

       // swap the value of i & k

       int tmp = i;

       i=k;

       k = tmp;

   }

   //third parameter gets smallest value

   if(j<k){

       // swap the value of k & j

       int tmp = j;

       j=k;

       k=tmp;

   }

}

// driver function

int main() {

cout << "Enter three integers: " << endl;

   // declaring 3 variables

   int num1,num2,num3;

   // reading the input

   cin >> num1 >> num2 >> num3;

   // calling the function

   Sort(num1,num2,num3);

   // printing the numbers after rearrangement

   std::cout<<"Numbers after rearrangement: \n"<< num1 << " " << num2 << " " << num3 << std::endl;

// main ends here

return 0;

}

Explanation:

First reading three integer in three different variables namely "num1","num2" and "num3".Pass these variable by reference in the function "sort()". There after comparing value of these three, largest value is assigned to num1, second largest value assigned to num2 and smallest value assigned to num3. Then it will print these value.

Output:

Enter three integers:

20 10 30

Numbers after rearrangement:

30 20 10

You might be interested in
Sample program for Do While loop<br><br> Qbasic
Ganezh [65]

Answer:

A "Do While" loop statement runs while a logical expression is true.

Explanation:

This means that as long as your expression stays true, your program will keep on running. Once the expression is false, your program stops running. A "Do Until" loop statement runs until a logical statement is true.

7 0
2 years ago
Read 2 more answers
An organization is conducting a study to see if hazardous waste sites pose health risks for cancer or other conditions, such as
denpristay [2]

Answer:

Emergency department information systems

Explanation:

I think this is the answer

8 0
3 years ago
If you are trying to create a web page for your band and having difficulty creating links to other groups on your page, what is
Georgia [21]

Answer: Malfunctioning of your hypertext program or malfunctions in your hypertext program.

Explanation: Hypertext is text that contains links to other texts. The HyperMedia is a collective term which can include graphics, video, sounds and texts, hence Hypertext.

The Hypertext also be said to be a special type if database system in which objects like Text, pictures, music, programs etc can be linked to each other creatively such that When you select an object, you can see all the other objects that are linked to it and you can move from one object to another regardless of if they have different forms or not. It was invented by Ted Nelson in the 1960s.

According to the question, when you are trying to create a web page for your band and creating links to other groups on your page, you are probably using the hypertext and if you are having problems doing this, then your hypertext linking is malfunctioning.

7 0
3 years ago
your computer running Windows 10 is doing some very strange things with operating system you are fairly certain it is not a hard
AlekseyPX
It might be a virus, when my computer starts going crazy i just bought a fixme stick and they work amazing or trying getting an expert to fix it if it worse
6 0
3 years ago
Read 2 more answers
Which type of app is the best choice when it is critical to be able to use the device's features but performance is not critical
Alchen [17]

Answer:

The answer is not native. I just got in wrong.

Explanation:

Edge 2021

4 0
3 years ago
Read 2 more answers
Other questions:
  • Where is the bubble level on a tripod?
    6·2 answers
  • A list of the slides in a presentation is found here.
    7·2 answers
  • The RAM is a type of ____ a.Main Memory b.Secondary Memory c.Human Memory d.EPROM e.EEPROM
    13·2 answers
  • A(n) ____ database is an application appropriate for an object-oriented database that contains text links to other types of docu
    7·1 answer
  • Let's say that you're the sole IT person in your company, and your boss wants a way to block certain websites from employees. Wh
    6·2 answers
  • Do you think that feedly will help you create an effective personal online learning environment? Why or why not?
    15·1 answer
  • Who predicted nearly 60 years ago that the rise of electronic media would create a "global village," thereby reducing the barrie
    12·1 answer
  • What is Brainly?<br><br> A.Yes<br> B.No
    12·2 answers
  • When you click the Decrease Font Size button, Excel assigns the next highest font size in the Font Size gallery.
    8·1 answer
  • Which of these could you use to change data into information?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!