THE FILE MUST BE NAMED smallSort2cpp Write a void function n

**THE FILE MUST BE NAMED smallSort2.cpp**

Write a void function named smallSort2 that takes as parameters the addresses of three int variables and sorts the ints at those addresses into ascending order. For example if the main method has:

int a = 14;
int b = -90;
int c = 2;

smallSort(&a, &b, &c);
cout << a << \", \"<< b << \", \" << c << endl;

Then the output should be:

-90, 2, 14

Solution

// c++ cde swap 3 numbers

#include <fstream> // file processing
#include <iostream> // cin and cout
#include <cctype>   // toupper
#include <iomanip> // setw
#include <cstring> // cstring functions strlen, strcmp, strcpy stored in string.h
#include <string.h>   // string class
#include <stdlib.h>
#include <vector>
using namespace std;

void smallSort(int *a, int *b, int *c)
{
   int t;
   if (*a > *b)
   {
       t = *a;
       *a = *b;
       *b = t;
    }
    if (*a > *c)
    {
       t = *a;
       *a = *c;
       *c = t;
    }
    if (*b > *c)
    {
       t = *c;
       *c = *b;
       *b = t;
    }
}


int main()
{

   int a = 14;
   int b = -90;
   int c = 2;

   smallSort(&a, &b, &c);
   cout << a << \", \"<< b << \", \" << c << endl;

   // output: -90, 2, 14

   return 0;

}

**THE FILE MUST BE NAMED smallSort2.cpp** Write a void function named smallSort2 that takes as parameters the addresses of three int variables and sorts the int
**THE FILE MUST BE NAMED smallSort2.cpp** Write a void function named smallSort2 that takes as parameters the addresses of three int variables and sorts the int

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site