//Sort array of 3 numbers #include using namespace std; void swap(int& n1, int& n2) //receive n1 and n2 by reference, exchange { int temp; temp=n1; n1=n2; n2=temp; } //swap void main() //input an array of 3 numbers, sort, print { int num[3]; int index; for (index=0; index<3; index++) { cout<<"enter a number "; cin>>num[index]; } //for if (num[0]>num[1]) swap(num[0], num[1]); if (num[1]>num[2]) swap(num[1], num[2]); if (num[0]>num[1]) swap(num[0], num[1]); cout<<"In order: "; for (index=0; index<3; index++) cout<