Respuesta :

Answer:

Following are the C++ language code to this question:

#include <iostream>//header file

using namespace std;//use package

int main()//defining main method

{

   int x[10];//defining array

   int i,j,t;//defining integer variable

   cout<<"Enter numbers \n";//print message

   for(i=0;i<10;i++)//defining loop for input value

   {

       cin>>x[i];//input value in array

   }

   for(i=0;i<10;i++)//defining for loop for sorting value

   {

       for(j=i+1;j<10;j++)//sort value

 {

  if(x[i]>x[j])//use if to check greatest value

  {

      //use swapping

   t=x[i];//hold value in t

   x[i]=x[j];//use swapping

   x[j]=t;// hold value t  value

  }

 }

       cout<<x[i]<<" ";//print array

   }

   return 0;

}

Output:

please find the attached file.

Explanation:

In the above program, an array "x" and 3 integer variable "i, j, and t" is declared, in the the main method, it specifies the for loop value that is accessed from the end of the user.  

In the next step there are two loops that use the if block, where they swap the value, and then prints their value after swapping.

Ver imagen codiepienagoya
Q&A Education