Respuesta :
Answer:
// here is code in C++.
#include<iostream>
using namespace std;
int main()
{
// declare variables
double num1, num2, mun3, t;
cout << "Enter three numbers: ";
// read the three numbers
cin >> num1 >> num2 >> mun3;
//sort the three numbers
if( num1>num2 )
{
t = num1;
num1 = num2;
num2 = t;}
if( num2>mun3 ){
t = num2;
num2 = mun3;
mun3 = t;}
if( num1>num2 ){
t = num1;
num1 = num2;
num2 = t;
}
// print the output
cout<<"numbers in ascending order:";
cout << num1 << " " << num2 << " " << mun3 << endl;
return 0 ;
}
Explanation:
Declare three variables to store the input. Read the value of all three variables. If first number is greater than second, then with the help of variable "t" swap the value of first and second.after that if second is greater than third number, swap them.In last if first number is greater than second one then swap them. This will sort the three numbers in ascending order.
Output:
Enter three numbers: 3 7 2
numbers in ascending order:2 3 7
The sort program can be achieved using the sort function and arrays.
The program in C++ where comments are used to explain each line is as follows:
#include <bits/stdc++.h>
using namespace std;
int main(){
//This declares an integer array for the three numbers
int arr[3];
//The following loop gets input for the three numbers
for(int i = 0; i<3;i++){
cin<<arr[i];
}
//This sorts the numbers using the sort function
sort(arr, arr + 3);
//This prints the sorted numbers, in ascending order
for (int i = 0; i < 3; ++i){
cout << arr[i] << ", ";
}
return 0;
}
Read more about sort programs at:
https://brainly.com/question/16397886