void sort(double &num1, double &num2, double &num3) { double temp; if(num1 > num
ID: 3634662 • Letter: V
Question
void sort(double &num1, double &num2, double &num3){
double temp;
if(num1 > num2)
{
temp = num1;
num1 = num2;
num2 = temp;
}
if(num2 > num3)
{
temp = num2;
num2 = num3;
num3 = temp;
}
if(num1 > num2)
{
temp = num1;
num1 = num2;
num2 = temp;
}
}
int main()
{
double Input1, Input2, Input3;
cout <<"Enter the first number: ";
cin >> Input1;
cout <<"Enter the second number: ";
cin >> Input2;
cout <<"Enter the third number: ";
cin >> Input3;
sort(Input1, Input2, Input3);
cout << Input1 << ", " << Input2 << ", " << Input3 << endl;
return 0;
}
Explanation / Answer
Dear Psuedocode Start Output"Enter the first number: " Read Input1; Output"Enter the second number: " Read Input2 Output"Enter the third number: " Read Input3 sort(Input1, Input2, Input3) Output Input1 Output Input2 Output Input3 End Function sort(Input1, Input2, Input3) if Input1 > Input2 temp=Input1 Input1=Input2 Input2=temp end if if Input2 > Input3 temp=Input2 Input2=Input3 Input3=temp end if if Input1 > Input2 temp=Input1 Input1=Input2 Input2=temp end if end function Hope this will help you..
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.