This is not the complete way to do it. It does ask for input and it sorts 2 groups of 2. But its a start to making it easier. Ill try and change it because now it only sorts it in two groups of two. Try it out though
Code:
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
void order(int*, int*);//prototype
int n1,n2,n3,n4;
cout <<"Enter first number"<<endl;
cin >>n1;
cout <<"Enter second number"<<endl;
cin >>n2;
cout <<"Enter third number"<<endl;
cin >>n3;
cout <<"Enter fourth number"<<endl;
cin >>n4;
cout<< "Before sort"<<endl;
cout<< "a ="<<n1<<endl;//before sort
cout<< "b ="<<n2<<endl;
cout<< "c ="<<n3<<endl;
cout<< "d ="<<n4<<endl;
order(&n1,&n2); //function call
order(&n3,&n4);
cout <<"After Sort"<<endl;
cout<< "a ="<<n1<<endl;//after sort
cout<< "b ="<<n2<<endl;
cout<< "c ="<<n3<<endl;
cout<< "d ="<<n4<<endl;
getch();
return 0;
}
void order(int* numb1, int* numb2) // swawp numbers
{
if(*numb1 > *numb2)
{
int temp = *numb1;
*numb1 = *numb2;
*numb2 = temp;
}
}